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. 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 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; } ?> Link to comment https://forums.phpfreaks.com/topic/78214-file-download-script-problem/#findComment-395804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.