Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To download large files from server, I have changed the below settings in php.ini file:</p> <pre><code>Upload_max_filesize - 1500 M Max_input_time - 1000 Memory_limit - 640M Max_execution_time - 1800 Post_max_size - 2000 M </code></pre> <p>Now, I am able to upload and download 175MB video on server. Since, I have the dedicated server. So, making these changes were easy.</p> <p>Below is the PHP script to download the file. I have no made any changes in this code snippet for large file size.</p> <pre><code>// 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; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload