Welcome Guest, Not a member yet? Register   Sign In
Force to download file
#3

(02-15-2018, 10:49 AM)InsiteFX Wrote: Force Download:

PHP Code:
$file "filename.ext";

// Quick check to verify that the file exists
if( !file_exists($file) ) die("File not found");

// Force the download
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Pragma: private');
header("Content-Disposition: attachment; filename="" . basename($file) . """);
header("Content-Length: " filesize($file));
header("Content-Type: application/octet-stream;");

readfile($file); 

Thanks
Reply


Messages In This Thread
Force to download file - by omid_student - 02-15-2018, 07:00 AM
RE: Force to download file - by InsiteFX - 02-15-2018, 10:49 AM
RE: Force to download file - by omid_student - 02-15-2018, 12:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB