home_directory; $folder = $_POST["folder"]; $filename = $_POST["filename"]; $dir = get_directory($folder, $user); if (!$dir) { error_log("/php/readfile.php - invalid directory"); http_response_code(409); exit(0); } $contents_of_dir = $database->get_links_of($dir); $file_node = null; foreach ($contents_of_dir as $c) { if ($c['name'] == $filename) { $file_node = $c; break; } } if (!$file_node) { error_log("/php/readfile.php - invalid filename"); http_response_code(409); exit(0); } header("Content-type: $file_node[mimetype]"); readfile("$storage_root/$file_node[code]");