- Google SEO
- PHP
- Mysql
- Ajax
- Jquery
- Photoshop
- Illustrator
- Database
- Web Design
- Web Development

TweetIn this article am going to explain you how to create PHP file downloader to download any files from web server to local machine. This application works mainly on the header of the PHP.

This type of file download script I have used in most of my web application. When you want to download any file you need to send the file name to this application, rest of the thing PHP will handle.
//set the time out set_time_limit(0); //path to the file $file_path='files/'.$_REQUEST['filename']; //Call the download function with file path,file name and file type output_file($file_path, ''.$_GET['filename'].'', 'text/plain');Now check the file for extensions and permission
//File size $size = filesize($file); $name = rawurldecode($name); /* Figure out the MIME type */ $known_mime_types=array( "pdf" => "application/pdf", "txt" => "text/plain", "html" => "text/html", "htm" => "text/html", "exe" => "application/octet-stream", "zip" => "application/zip", "doc" => "application/msword", "xls" => "application/vnd.ms-excel", "ppt" => "application/vnd.ms-powerpoint", "gif" => "image/gif", "png" => "image/png", "jpeg"=> "image/jpg", "jpg" => "image/jpg", "php" => "text/plain" );
Phil Tyler
Thursday-Nov-2011 | 10:21:23 PM
The script seems great but when I try use it to download a 155Mb ZIP file it stalls and stops around the 130Mb-147Mb mark. The only error message is "download interrupted". The config of the server at FastHosts can be seen by visiting www.godfreyb.com/_scripts/test.php
Can you suggest what might be wrong? If I directly create a hyperlink to the file in HTML and click it then it downloads perfectly and the ZIP is intact.
![]() |
Blogger,Web Designer, Developer, Programmer
|
Subscribe via email to get updates
Category
- SEO (7)
- Web Development (25)
- Web Designing (9)
- Graphic Designing (12)
- HTML5 (2)
- Flash (5)


