To download large files from the server, I changed the settings below in the php.ini file:
Upload_max_filesize - 1500 M Max_input_time - 1000 Memory_limit - 640M Max_execution_time - 1800 Post_max_size - 2000 M
Now I can upload and download 175MB video on the server. Since I have a dedicated server. So these changes were easy.
Below is the PHP script file to download the file. I have not made any changes to this code snippet for a large file size.
// Begin writing headers ob_clean(); // Clear any previously written headers in the output buffer if($filetype=='application/zip') { if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); $fp = @fopen($filepath, 'rb'); if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { header('Content-Type: "$content_type"'); header('Content-Disposition: attachment; filename="'.$filename.'"'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-Transfer-Encoding: binary"); header('Pragma: public'); header("Content-Length: ".filesize(trim($filepath))); } else { header('Content-Type: "$content_type"'); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Content-Transfer-Encoding: binary"); header('Expires: 0'); header('Pragma: no-cache'); header("Content-Length: ".filesize(trim($filepath))); } fpassthru($fp); fclose($fp); } elseif($filetype=='audio'|| $filetype=='video') { global $mosConfig_absolute_path,$my; ob_clean(); header("Pragma: public"); header('Expires: 0'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: application/force-download"); header("Content-Type: $content_type"); header("Content-Length: ".filesize(trim($filepath))); header("Content-Disposition: attachment; filename=\"$filename\""); // Force the download header("Content-Transfer-Encoding: binary"); @readfile($filepath); } else{ // for all other types of files except zip,audio/video ob_clean(); header("Pragma: public"); header('Expires: 0'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: $content_type"); header("Content-Length: ".filesize(trim($filepath))); header("Content-Disposition: attachment; filename=\"$filename\""); // Force the download header("Content-Transfer-Encoding: binary"); @readfile($filepath); } exit;
ursitesion Apr 11 2018-12-12T00: 00Z
source share