know_php Posted November 21, 2007 Share Posted November 21, 2007 I am using this script for downloading of a file, but it doesnt do anything when i click on download. header("Content-Disposition: attachment; filename=$name"); header("Content-length: $size"); header("Content-type: $type"); Please suggest way to do it successfully. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/78214-file-download-script-problem/ Share on other sites More sharing options...
pkSML Posted November 21, 2007 Share Posted November 21, 2007 You might see this script --> http://elouai.com/force-download.php Quote Link to comment https://forums.phpfreaks.com/topic/78214-file-download-script-problem/#findComment-395802 Share on other sites More sharing options...
~n[EO]n~ Posted November 21, 2007 Share Posted November 21, 2007 Like <?php session_start(); ob_start(); include("include/userconfig.php"); // here i am downloading PDF $filepath="userdownloads/myfile.pdf";; $filename="myfile.pdf"; downloadFile($filename,$filepath); function downloadFile($filename,$filepath) { header("Content-type: application/pdf"); header("Content-disposition: attachment; filename=".$filename); header("Content-Length: " . filesize($filepath)); header("Pragma: no-cache"); header("Expires: 0"); readfile($filepath); return; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/78214-file-download-script-problem/#findComment-395804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.