Free php and cpanel scripts to automate your daily routine

Free PHP Scripts :: Smart File Download

Use Smart File Downloader to avoid direct files downloads (hide real file paths), and to limit downloads to only some set of file types.

  • customizable allowed file types for download
  • predefined mime type settings for following extensions: zip, pdf, doc, xls, ppt, exe, gif, png, jpg, mp3, wav, mpeg, mpg, mpe, mov, avi
  • Hotlinking protection
  • Script can log downloads in plain text file. Log file includes: IP, date/time, filename. Can turn this feature on/off.
  • automatic mime type detection (if Mimetype or Fileinfo extension installed on the server)

  • Unzip script to some folder
  • Update download.php with your desired settings for base downloads folder, downloads log file name, allowed file types
  • Use following syntax for downloads: download.php?f=FileName

Sample download link:
<a href="http://path/to/script/download.php?f=phptutorial.zip">Cool PHP Tutorial</a>

Make sure you set write permissions on the folder where downloads log is saved if you turned downloads log feature on. Otherwise you may experience file access permissions issues (log file will not be created/updated).
All files for download must be placed in the download folder you specified in the script settings.

Download Smart File Download


Matt August 1, 2006
Works great! Thanks!
August 4, 2006
odd that you don't appear to use the script itself to distribute the download on this page...

zubrag: We don't use it on zubrag.com because we are not trying to avoid direct downloads, and for downloads tracking we use Google Analytics. Google Analytics will not track direct downloads, but it is not a big issue.
martyowens [anti-spam] gmail.com August 5, 2006
Nice. In the 7th header line, is the ; after ...filename=$fname;); an error?
I mean the ; inside the end ).
genzoeri [anti-spam] gmail.com August 5, 2006
Really,, nice job. Thanx zubrag, I am waiting for your other script.
Annoyed August 8, 2006
Too bad thee is no instructions on how to add the downlad links to the page. What I find on this page is quite vague!!!
August 9, 2006
Thanks for this script. Had used others in the past that produced errors but this one works fine. Danke :)
george.tyrakis [anti-spam] gmail.com August 11, 2006
Awesome script! 1 question though, is it possible to make this script display some html and then give the download? Please help as I have a project due in very soon!

zubrag: why don't show HTML first from your application, and from that HTML give the download link? For example you might have webpage "X" wich lists some products for download, and each product has link to the HTML page "Y" (the HTML page you want added to the downloader), which would contain actual download link. Such solution seems to be more flexible since you would have more control over it. Wouldn't that work?
him August 13, 2006
heh.. just right click -> open in new window and file's URL appears ;>

zubrag: that way you'll only get "download via this downloader" URL. It will not reveal the real file path, thus avoiding direct downloads.
Kaali August 13, 2006
Hello! I want to ask that is download.php should be in same directory as the files which are to be downloaded with this script.

Because this error is displaying:

File does not exist. Make sure you specified correct file name.

my download.php is located in

& downloads are located in

why the error is coming?

zubrag: you can place download.php where you want. Try putting absolute path (i.e. path from the root folder) in the BASE_DIR. In your case following relative path should also work: define('BASE_DIR','downloads/');
MrDude August 15, 2006
Great script but doesn't work with Internet Explorer 6+?

zubrag: strange, it works fine with my IE6 and Firefox. Could you provide more details?
agnesabert [anti-spam] yahoo.com August 17, 2006
i want U to posted it to me
blueberryjuice [anti-spam] gmail.com August 19, 2006
i'm using winXP, it is successful when download a zip file, but after download a pdf file the file seems corrupted, it cannot be opened with acrobat reader, any suggest? thx

zubrag: Cannot reproduce this problem. Can you provide more details? Your browser name, version? Maybe you are trying to download already broken file?
olloo August 23, 2006
shoaibi September 3, 2006
Suppose if i want to add rmvb, rm, mkv, ogm, mp4, files to the allow file types, how should i do it?

zubrag: update allowed_ext array with your new allowed extensions, and its mime type.
For example here we are adding mp4:
// video
'mpeg' => 'video/mpeg',
'mp4' => 'video/mp4',
'mpg' => 'video/mpeg',
To determine mime type for some extension just google extension with "mime type". For example mp4 mime type. You can leave mime type empty if you cannot find correct mime type. In this case above block will look like:
// video
'mpeg' => 'video/mpeg',
'mp4' => '',
'mpg' => 'video/mpeg',
phoenix.suresh [anti-spam] gmail.com September 4, 2006
Hi zubrag,
This is really a great Script. Its full filling all my needs. But I have a few problem. where as my filename has space inbetween it.

For example:
file name.jpg

so when I click the link im getting "File does not exist. Make sure you specified correct file name." Error can you please help me to fix this problem.
Great thanks,
M. Suresh
nixforge [anti-spam] yahoo.com September 5, 2006
Hi all
how if want to download from another site >
moviespot [anti-spam] as.ro September 9, 2006
I'm trying to use your code in moviespot.as.ro/download.htm. It works for 2 small files but not with a 750KB file (first on page). Is there any way to "bypass" the server?
mailme420 [anti-spam] gmail.com September 13, 2006
my file is located in another server which don't support php. from my site server which support php but there not enough space. how can i use this script, if i want to give user to download a file from file server without seeing file server url & with web site server url?
maznos [anti-spam] gmail.com October 4, 2006
is it possible to integrate it to VBulliten
jake [anti-spam] capcoa.org October 19, 2006
I can't get the log file to work. I have both the folder and log file itself chmodded. I even tried to let it create one on its own and it didn't. Suggestions?
jake [anti-spam] capcoa.org October 19, 2006
I got the log working. I'm not sure you coded it to look for the downloads.log in the $base_dir. It was trying to find the file in the current directory it was at. I had to point it to the $base_dir where my downloads are kept.

just a thought.
x [anti-spam] homemadebyx.com October 31, 2006
Nice Script! A solution to this isn't vital, but if the file being downloaded has spaces in the filename, the script replaces spaces with underscores. Is there a way to maintain spaces?
Anton December 2, 2006
how could i do that

1. i have the folder set to /path/to/folder/ but i have sub folders like:

where my files are located

2. i want to name the filename diffrent then what it is in the folder, example.

i have filename in there called:
testfile.mp3 but i want to called it when the user saves it as myfile.mp3

so i can get these settings from a DB.
Jay Edgar December 6, 2006
Great script - this is exactly what I needed for the seed of my secured download system. Thanks much for creating it!

December 12, 2006
Thanks for the time spent on this code.

something strange is happening. this code is working well with firefox but whilst using IE7 the browser displays the text in the file, those funny characters that appear when trying to open an audio file using notepad; no download is taking place. What could be the problem?
December 12, 2006
just found out the solution to my problem i highlighted above.

i added:
header("Content-Type: application/octet-stream");

to the headers.

Thanks for the code once again.

erik December 22, 2006
Great script! However I too cannot get the logs function to work. Folders are all set to be writeable, but no information is added to the log file itself.
gene kamote January 3, 2007
hey zubrag thanks alot for the codes..
January 7, 2007

This is the error I'm encounting at the moment. Any chance of explaining what is happening?

Currently running on a Linux Machine. Trying to download file from IE 6
Warning: opendir() [function.opendir]: open_basedir restriction in effect. File(/Resource/IST07/) is not within the allowed path(s): (/home/teaching/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/teaching/public_html/Junior/downloaddata.php on line 83
jorgemajjul [anti-spam] msn.com January 12, 2007
Hi I'm looking for a script like www.driverguide.com, because I have a lot of drivers file to share in my server.

Please let me know if this is possible with Smart File Download

Thanks a Lot
serkan [anti-spam] kariahouses.net January 17, 2007

The script is very usefull, but for pdf files, you can download only up to 1,9 MB and the download process stops. And it says that the file is corrupted if you try to open it. Interesting problem.
Sam January 18, 2007
Wow that is awsome. I was looking for some code for that functionality for hours on the internet. I am happy I finaly found a solution :)

Thank you
solidus.it [anti-spam] gmail.com January 23, 2007
Hi, I found this script very useful.
I'm wondering if is possible to allow downloads with a download manager, such free download manager, when I start the downloas, it auto stop.
harshinichandra [anti-spam] yahoo.com January 27, 2007
hi..i need a script for access log.i ll be a very grateful if u mail with in one week..its badly neccessary for our project!!!
March 6, 2007
Great product. installed in seconds. worked perfectly 'out of the box'.

greatly appreciated.
posterlu March 12, 2007
The recursion into subdirectories does not quite work. It for example takes the first file by a certain name it finds and uses that. Try having it bring images that have both fullsize and thumbnail versions =)

I bypassed this by using the direct url, but checking that the realpath(url) is within base-url.
hossein_2hi [anti-spam] hotmail.com March 17, 2007
very nice script, and its working VERY nicely.

great job.

in my site .zip files download fine, and .avi files download fine.

but i have .rmvb files. and i've changed the mime type, but now i get wird letters, and they keep loading till my IE crashes.

I just wanted to konw how to allow all files, regardless of the mime type.

hossein_2hi [anti-spam] hotmail.com March 17, 2007
i tried to include download.php in my index.php.

the download.php?f=file.zip works fine
but index.php?page=download&f=file.zip shows internal server error
tulsadavid2007 [anti-spam] yahoo.com March 24, 2007
Thank you very much for sharing your code. Can you (or anyone reading this) help in one area that isn't working? Whenever I create dynamic content (NOT a file) and want to "echo" that out into a filename, it will not work on FireFox using Free Download Manager. FDM picks up the original URL and downloads that instead. IE works just fine.

Any header protocols for FDM?
mitridates May 8, 2007
Perfecto, justo lo que estaba buscando. Muchas, muchas gracias.
djsolin [anti-spam] gmail.com May 10, 2007
"File does not exist. Make sure you specified correct file name."

This is the error I get when I have installed the script. Yes, I have tweaked this with the directory in which I have the files in; not only with the lame path:




AND it is still giving me the error!! Please fix this! ;)
djsolin [anti-spam] gmail.com May 10, 2007
For some reason when I changed the name in my file that I was working with, this script actually worked fine. It has a bug somewhere that needs to be fixed and hopefully you can find it. For now I will mess with it until I decide otherwise.
May 18, 2007
I am also getting this error:

"File does not exist. Make sure you specified correct file name."

I've tried all manner of variations on the

Apin May 22, 2007
i think i found something

mad_noer [anti-spam] telkom.net May 30, 2007
terima kasihlah atas bimbingannya!!
viva zubraq !!!
venkatpammi [anti-spam] yahoo.co.in June 11, 2007
djzmo June 11, 2007
it works..
btw, this script is veeeewwyyyyyy nicee~~!!
thanks ;)
Raghu June 14, 2007
Yahoooooooooooooooooooooooooo.It's Working Well.Thanks To The Script Author.
talya.nevo [anti-spam] celeno.com June 24, 2007
I am trying to use the script to download more than 1 file and can not. Do you have any suggestions - thanks.
John June 25, 2007
Hi. I recently installed Smart File Download and have come across a few problems maybe you can help with.

This is how I set up the code using my site's name where mydomain.com goes below


// log downloads? true/false

// log file name

I chmod it to 766 since it did not work with 644
Is there anything on the lines above you think I should change in order to make the script work?. Thanks for helping
June 29, 2007

1.Edit your absolute path so it look something like this.

Those who get error because you forgot to put "public_html". If you enable log, you need to chmod the folder to 777. Because you need to chmod, you don't want to use your root right? so I create a folder call "downloads" and chmod it to 777.
2. Upload your PHP file to the "downloads" folder.
3. Put all your download to your "downloads_999"
4. your download link should look like this

JT July 1, 2007
all working, nice and easy, thanks!


You can still copy link location (http://www.MYSITE.com/includes/download.php?f=sample.zip )paste into new browser and the file downloads without any issue? Am I missing the point here?
Laban July 2, 2007
Code of great value here. Bumped into a problem today. set_time_limit is rejected by safe_mode, and if errors are displayed headers won't go, and there you go for file content display in page.

You can remove set_time_limit line, or modify errors settings. Chose first.
Rene July 6, 2007
Very neat and very usefull script! Excellent work, thanks!

One remark: the logfile only works if you include the full path in the logfile name ;-)

Naveen July 8, 2007
Is there anything special to do with Content-Type for .rar files
Gav July 9, 2007
how do i make this work with .iso files
mariogarcia_ar [anti-spam] yahoo.com July 17, 2007
Hi, Great Job
Mario Garcia
nicelens2000 [anti-spam] yahoo.com July 18, 2007
excellent .. thanks
spam [anti-spam] idle.se July 21, 2007

Works fine for .pdfs but when i try with a .doc the .doc is corupted when downloaded thru the script, also the .pdf reader asks every user if they want to save changes after they have only viewed the .pdf. Im running apache under FreeBSD. Is there anything i could check?
arwin July 22, 2007
for MIME Reference:

July 24, 2007
Thanks++ put to use in my website.. just wanted to ask.. does this have any known security issues ?
Vinod July 31, 2007
I am running this script on one server with fine results, but at the same time using on other server file gets corrupted on download. WHY?

Can u please help me.

Thanks in advance
August 5, 2007
Hi. I read somewhere here that in the define (BASE_DIR) area no URL should be included, but yet I read someone here used his domain name instead and got confused. Could I include my domain name without the http:// or is that meaning the root server for the domain name should be included instead?. Thanks for helping
saurabh August 23, 2007
I am a complete novice and trying to put this feature on my website. I have no idea what a root server is. I am using front pafe to design the website. Can someone tell me step by step what needs to be done.
sameema August 27, 2007
Works good. Thanks to the script author.
August 27, 2007
Download Resume supported???
tnp September 1, 2007
Nice code. I don't need it as it is, but it serves as a good example for what I am doing.
Adam September 17, 2007
thank you very much for this script, it works really well, and so easy to use
Black Smoke September 20, 2007
Wow... Really i found awesome. thanks... Guys for creating this solution...

Great Work Guys...

from Sag-e-Attar Junaid Atari
javed_kgardezi [anti-spam] yahoo.com September 24, 2007
I am using win xp, any one can complete guide me how to use Smart File Download. Some one explains the steps to use Smart File Download in windows XP. plz email me at javed_kgardezi@yahoo.com
i shall be very thanksfull to you.
Scott September 27, 2007

This is the error I'm encounting at the moment. Any chance of explaining what is happening?

Currently running on a Linux Machine. Trying to download file from IE 6
Warning: opendir() [function.opendir]: open_basedir restriction in effect. File(/Resource/IST07/) is not within the allowed path(s): (/home/teaching/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/teaching/public_html/Junior/downloaddata.php on line 83

Some web hosts prevent you from accessing files outside of your directory_root directory. That is what causes this error.

If you are using byethost.com or swiftphp.com (same company same restrictions) you can not access files outside of directory_root.
yanyan October 5, 2007
thank you thank you sooo much. you helped me alot. :)

God bless
admin.virtual [anti-spam] gmail.com October 7, 2007
i want to be able to download a random file from a set of files in a folder. could somebody sugest how to do that.
Bokito October 7, 2007
Thanks, really usable and well documented script. I will be sure to check out the other stuff on your site. Thanks again!
cfor011 [anti-spam] hotmail.com October 8, 2007
I want to be able to download doc file or pdf file could somebody sugest how to do that
multimedia [anti-spam] amvdesign.it October 16, 2007
Good job! it really works
October 17, 2007
It's great it's work very good...
Matt October 18, 2007
You = lifesaver. Thank you so much for this script.
pervez_musharraf October 20, 2007
Excellent script. Suprised you have been able to achieve this with just one page. There is a similar script at gentlesource. However, it has a complex structure and leaves its url on each file (big nuisance). It is able to count the downloads for each file (advantage) while yours lists each download separately. Good work.
Wagner October 28, 2007
Muito Obrigado, Funcionou Perfeitamente!!!
I Will find for a simple and functional script like this!
manasan2002 [anti-spam] yahoo.com November 14, 2007
The script is not capable for multi threading. I can only download one file at a time.
November 20, 2007
You should include an updated script to protect filepaths even more. I modified the script so that it picks up the filename from the database, and hence you only supply an ID for the download.
Downloads then look like this: domain.com/download.php?id=30
John R November 23, 2007
Excellent php script! Simple and elegant. Worked well from the beginning, and easy to customize and integrate into my site - Thanks!
Slava S November 23, 2007
I just wanted to thank you for this excellent script. Easy to integrate, works fine righ away.
acakeb10 [anti-spam] caledonian.ac.uk November 26, 2007
Notice on download it only allows one port for download. Any way I can change this?
rawat167 [anti-spam] gmail.com December 15, 2007
Please Help Me I want to do download any file on your system while click on giving link
robby December 19, 2007
Works perfectly! This was just the example for which I was looking.
Salik December 20, 2007
Absolutly Fantastic Work (Y)

i hope this work is fully secured
madhus.spl [anti-spam] gmail.com December 28, 2007
Thanks zubrag.com this is script used for me a lot
thank you very much.........
this will surely help us very much to secure our site
thanks Lot once again...
Chief_runningwater January 8, 2008
Won't seem to work for me
January 9, 2008
it doesn't work for me :S
"Warning: opendir(/home/user/downloads/) [function.opendir]: failed to open dir: No error in C:\apache\www\download2\download.php on line 95

Warning: readdir(): supplied argument is not a valid Directory resource in C:\apache\www\download2\download.php on line 97
File does not exist. Make sure you specified correct file name."
rohit sharma January 10, 2008
can any body give php script to send email to inbix
January 13, 2008
Hi. It took a couple hours but I figured out how to make this script function. And unlike some that will only give bit and pieces for you to puzzle together for your self, I will send a detailed "how to" file along with all the components to whomever wants it. Just email me at turner2f@yahoo.com Cheers! Thanks for making the script!
geo January 16, 2008
Hello, Thanks a lot, keep up the good work
January 19, 2008
I have the script working, but for some reason I can't get it to track .wmv video downloads. When I use it to track a .doc it works fine so i know i got my paths, and permissions set right.

I added:
'wmv' => 'video/x-ms-wmv'

So it lets me download it but it just doesn't track this specific filetype.. Am I doing anything wrong here?
markaf [anti-spam] mit.edu January 21, 2008
Great script, thanks very much for putting it up. I have one minor question: using IE6 to download a file, say, edu.uni.java_1.0.0.jar, I get "edu[1].uni.java_1.0.0.jar" as the 'save as' filename. Any ideas why, and any fixes known? Many thanks for your great script.
alto [anti-spam] bluebottle.com January 26, 2008
hi zubrag

thankyou thankyou, this script looks good!
thankyou for all your efforts and sharing them with us ...

everything working ...
i have 2 needs
how do i force "save as" dialog.
when in IE, the download immediately is downloaded by my download manager which opens and begins downloading, revealing the download URL.
cannot utilise your wonderful script until i can force"save as"

any clues for me?
thankyou for your time...
eric [anti-spam] designedbyeh.com February 1, 2008
Can I use this across two different domain? I need to store media files on a different server? So, can the path be to a different domain?

February 4, 2008
i really need to know how to read .txt,.html,.pdf and .doc file using php codes?
DasBrose February 6, 2008
Nifty! A very useful script.
yuri [anti-spam] post.com February 13, 2008
The Best script in the Net.
If authors could add temporary functions to it to avoid constant downloading for payed links - it could be the most substantional contribution of PHP in our lifes!
uma February 16, 2008
i want to attach a pdf file without using browser control
radman February 19, 2008
thanks for the file. I will use it in my new site: http://www.midisharing.cn
belcherds [anti-spam] concord.edu February 19, 2008
I am a novice programmer (at best), when I used this script, and clicked on the link that should have brought up the download, it displayed the code for the download.php page. Can anyone help me configure this better? thanks
senthilk [anti-spam] peppersquare.com February 22, 2008
Code is superb. But can you give me one example file to do easily. That is very useful for new programmer. Thanks. Great!...Code.
dwmsyron February 25, 2008
You have a section towards the end to remove bad characters, eg:
" ' \ /

You might want to change this to:
\ / : * ? " < > |

These are valid on many file systems, but they are invalid on Windows:

Thanks for the script!
March 7, 2008
Great script Zubrag!
Is it easy to add a timeout on the links? Time out after downloaded 3 times from certain IP address. I'd definately pay for this.
jllanten [anti-spam] rocketmail.com March 14, 2008
Works great ! thanks a lot for the script. Will keep on visiting more this site
Andrew March 18, 2008
Thanks, works great. Appreciate you making this available, you just saved me a few hours...
razibmiah [anti-spam] gmail.com March 20, 2008
I am using this www.razibmiah.com
gadelkareem.com March 23, 2008
yes timeouts should be a great addition..
asasha March 23, 2008
would this script be indexed using http://gadelkareem.com/2007/12/10/sitemap-creator-02a-create-sitemaps-09-valid-for-google-yahoo-and-msn-sitemaps/
is it seo wise ?
levi March 25, 2008
works great - thanks for the effort
ktweezee [anti-spam] yahoo.com April 1, 2008
great script. i used it with a form to obtain some data before downloading. awesome!
April 2, 2008
How can I add the username (an maybe soemother information) to the logfile? Users have to auth with an NIS account to get to the webpage, but I don't know how to grab the username and add it.

April 4, 2008
Ardian April 6, 2008
Kevin April 8, 2008
Muchas gracias!
hrvoje April 9, 2008
I added
'tar' => 'application/x-tar',
'tgz' => 'application/x-compressed-tar',
'tar.gz' => 'application/x-compressed-tar',
under archives group
binu April 16, 2008
ceeby April 19, 2008

Having some real trouble getting this to work :( It's back to the "Cannot Find Directory" problem.

When I see this:

Am I to think that everything other than "home" is to be changed to my own particular information?

Just trying to figure this out... I'm a noobie so I'm having some trouble.

My site is www.ceebysite.com and the download.php file resides in www.ceebysite.com/movietestflash/download calling for the file "download.zip" in the same directory.

Here's the total path that comes up when I try to run it:

Any advice?

Many thanks in advance...

kimwatts2003 [anti-spam] yahoo.co.uk April 21, 2008
Works fine. Had to include the rar mime type but other than that, no problems.

April 22, 2008
Very nice, thank you for this!!
April 24, 2008
Zubrag, you must have a step by step procedure along with the Php script for us stupid people who are new to php.
timG April 28, 2008
Below is what I get when I press the link to download.

Warning: opendir(/downloads/): failed to open dir: No such file or directory in /" "/download.php on line 95

Warning: readdir(): supplied argument is not a valid Directory resource in /" "/download.php on line 97
File does not exist. Make sure you specified correct file name.

this is the full path to the file I want downloaded

This is the link
<a href="http://iced-preview.com/download.php?f=downloads/BookStore_Pricing.psd">Download Price List</a>

This is what I put for the directory

I also tried it with the full path and got the same result.

I'm sure there's a simple solution to this but I'm very new to php so I would appreciate any help. thx
Freak April 28, 2008

You have to erase the slash in front of download. Then it should look like this:


and work just nicely.
May 2, 2008
Hey, Is there any way to download file using this script present on other server?
hiding the actual url of site and its location?

Best Regards,
Ritesh Jain
May 3, 2008
tolvhundra [anti-spam] hotmail.com May 5, 2008
Please help me!!! it works with FF but not with explorer or safari to download files.. if i download it with safari and i try to open it i get a error message "broken file" what do i do? please help me!!
aliaydin May 6, 2008
nice job and thanks
May 7, 2008
Thanks dear.. its very easy to integrate. had intergrated it..


May 13, 2008
Script is working great..
But i am using this script for video downloading...
But the file is open and play automatically...
what is the solution for that...
gee [anti-spam] exclusivemail.co.za May 15, 2008
Hi! This is the error i'm getting please help me. I've tried to change define('BASE_DIR',"") but still...
martin [anti-spam] prefix.co.za May 15, 2008
When you tried to open files directly from the brower, it will download but give an error when trying to open the document.

Thanks so much. We have had this problem in IE6 for a long time and this resolved this issue.

Thanks again.
kaspar.mary [anti-spam] gmail.com May 16, 2008

Its nice and simple script. any one can understand, thanks a lot for giving this.

am facing one in this script - i can download the file from my site into needed folder but i cannot open it, because it just copy the name of the downloaded file only, there is no content in this, thats y i cannot open/play it.

Plz give a solution for my problem to my mail id.

Actually am testing this localhost only
am getting confusion to give path.
C:\Program Files\EasyPHP1-8\www\project_name\downloads.

now am giving the base_dir - './downloads'.

chinmayee May 19, 2008
hey.. it's working fabulous...
thanks a lot for giving this free script..
ashwani.bhardwaj154 [anti-spam] gmail.com May 25, 2008
i want to download php file reader
142905 [anti-spam] gmail.com May 25, 2008
This script works fine with Mozilla and IE6 but still not working with IE7... The page takes a lot of time to load (as if its processing the request) and then gives an error;

Internet Explorer cannot display the webpage

Any ideas....
riesurya May 28, 2008
I've been using this great script since ver.1.21 and it works well. Tx a lot
Spinner May 29, 2008
The main thing about this page is that everything is just too vague for me! I can barely even understand what I'am about to do next as I install this script into my directory!

What do I do?
Who knows!

The page at zubrag.com that claims to have developed the script left me with xxxtremely inadequate instructions on how to use, install, and modify this script!

I tell ya,

Best Regards
June 7, 2008
Wow. Simple. Thanks for the script. Took about 2 minutes to customize and upload to server.

If you're having trouble you either don't have a php enabled server or you need to take a lesson in basic web development.

-Thanks again,
ryan June 16, 2008
I have searched 4 months 4 a script like this, You guys are great OPEN SOURCE 4 life, i love this script it saves me
from loseing bandwidth and from prying eyes everyday.
June 17, 2008
damn people, how 'bout reading the damn comments on the file?

why are you bitching that you cannot use the script? did you paid for it?

if your skill is not enough to tamper with basic code, then look for commercial solutions, I bet there are plenty out there.

thanx for the script dudes.

(I'm struggling with the hotlinking part, but I'll get around to it)
June 17, 2008
Excellent script. Thanks a lot
newbie June 18, 2008
need tutorial for the code..
someone plz help..
ximenamay [anti-spam] hotmail.com June 24, 2008
Works great! I had to struggle with the path but it just took me some minutes. Thank you for your generosity
&#1053;&#1077;&#1085;&#1072;&#1076; June 24, 2008
It is just excelent code, working perfect. Nice job, and thanks a lot.
matrim [anti-spam] usbanime.com July 9, 2008
Script works nice. though I made a change for security reasons.
changed :
$fext = strtolower(substr(strrchr($fname,"."),1));

$fexplode = explode(".",$fname);
$fext = $fileexp[count($fileexp)-1];

This in order to prevent the use of . in file name
if a file is named "john.doh.jpg"
the original script puts "doh" as the $fext, what mine does it that it always takes the last argument, putting"jpg" in the $fext variable
matrim [anti-spam] usbanime.com July 9, 2008
Just noticed that I missed the strtolower();
$fexplode = explode(".",$fname);
July 10, 2008
Great script and thanks!
consultant.ankit [anti-spam] rediffmail.com July 15, 2008
First of all thanks for your great scripts but don't know why its not working for me. The filesize function is throwing an error:
Warning: filesize() function.filesize]: stat failed

Does anyone have idea why is that??

Chandan July 15, 2008
One question, is there a way we can show download url of our site and it actually should download from some other site. ex :- www.mysite1.com/download.php?f=test.txt should download file from site2.com/test.txt ???
aliceander [anti-spam] gmail.com July 16, 2008
Thank you for the script.

Is there a SIZE limit? It works on small to medium size files but a file that is over 2gb is having trouble finding (file not found by the download script).

Will try to solve but please let me know if you there is some limit that I am unaware of.

Thanks again.
emiliodelrosarioiii [anti-spam] gmail.com July 21, 2008

Need some help on the error "File does not exist. Make sure you specified correct file name."

And I've made a lot of tweaks. Anybody have any fix on this. thanks!
toto July 22, 2008
about file not exists, what i did it s to put the downloaded folder in the same dir (example, you put the dl.php in /home/dl/, you have to put the downloaded folder in /home/dl/downloaded/), after in the dl.php, put :
tata July 22, 2008
there is a way to add a limited download number ????
there is the expire function but i would like to limit the download.
for example, only one person/ip can download 2 times, after that got error
thanks for any help
britney July 22, 2008
you can limit download number or time file is available here

Eva July 25, 2008
Hi everybody
I used this script befor and it was great. i changed our server and i put the new path because is not the same. it not start by home but by var
define('BASE_DIR','var/www/hghj/html/library/');it appear this message
Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /var/www/hghj/html/download.php
san_about [anti-spam] yahoo.com July 27, 2008
How to open up that php file.
can u please provide some Details
Anthony August 1, 2008
Really thanks for the script ^^
arvind.softwarex [anti-spam] gmail.com August 6, 2008
Nice script,working perfectly.
Thank you
arvind.software [anti-spam] gmail.com August 6, 2008
Nice script working excellent.
Thank you
webwareshop [anti-spam] yahoo.com August 6, 2008
This script works fine.
For those of you with problem read this:
Hello! I want to ask that is download.php should be in same directory as the files which are to be downloaded with this script.

Because this error is displaying:

File does not exist. Make sure you specified correct file name.

my download.php is located in

& downloads are located in

why the error is coming?

zubrag: you can place download.php where you want. Try putting absolute path (i.e. path from the root folder) in the BASE_DIR. In your case following relative path should also work: define('BASE_DIR','downloads/');

This is the kind of problem people are having
John UK August 10, 2008
Really useful, thanks alot.
gbl0330 [anti-spam] gmail.com August 11, 2008
Nicely Done! Thanks
bluly2000 [anti-spam] yahoo.com August 12, 2008
i am having error as "Warning: Cannot modify header information - headers already sent by (output started at /home/x4wards/domains/4-wards.com/public_html/user/download.php:2) in /home..."
What can I do??Is it any sample working link that I can refer?
August 14, 2008
Thanks man your the One
But i wanna ask how to enable Resume Download
Anatolij August 18, 2008
I've added also mod_rewrite rule to complete the cool functionality. You can use this one:

RewriteEngine On
RewriteRule download/([a-zA-z0-9\.\-]*) download.php?f=$1

Add to yout .htaccess file and you can access your files viw the: www.yourdomain.com/download/your-file-name.ext

mahmud_shaheen [anti-spam] yahoo.com August 20, 2008
i download it.i am new programmer .where to change please tell me.i use wamp server.
August 20, 2008
zion August 21, 2008
Hello, Thanks for your great work.
but I have some problem.
When i place links in flashget, its seem i can't continue download file but to restart download again.

How can i allow to continue download via flashget?

mahmud_shaheen [anti-spam] yahoo.com August 21, 2008
i want to use your scripts.please help me.i download your script and save C:\wamp\www\downlaods folder. and same for log file C:\wamp\www\downloads.log
but i don't understand where to put download web site or link or URL .suppose i want to down load this link "http://www.4shared.com/file/54305152/cea4d5c0/System_Analyst.html.please help me.i am very new.
manas.mailto [anti-spam] gmail.com August 21, 2008
Good Script,
I found exactly what I want
tina August 23, 2008
Hello and thank you for a great script. I had it up and working within 20 minutes. Wow. Good job.
Shravan August 23, 2008
Very useful script!! Good Job!
Chetan August 24, 2008
I was looking fot this and hti is really Amazing!
Chetan August 24, 2008
Hey guys.. i accessed the log file and it displays
something like
08.23.2008 7:31pm CUJNBsow1UPAeMz0DHXG.MP308.23.2008 7:35pm UJrfDOiuool1QhxEC1b4.mp3

that would be great if it can make some spaces before starting the Next Mp3 file... Because that will be easy to look into it..

i tired adding few spaces after @fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$fname."\n"); but it never worked... please Help.
Emil August 25, 2008
Good script!!!
I would like to ask if this script can allow force downloads? Because I usually have our users download PDF file, I need them to download it directly on their computers. Thanks.
satinoctopus [anti-spam] gmail.com August 26, 2008
I wanted to build a script to download a PDF file after extracting it from a zip file in order to save disk space. I took the script proposed here as example, and i wrote a code that works well in Firefox, but in IE 7, I get a message saying that the file could not be opened because the file is not of the right type or because it is damaged.
This is the relevant code:

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=\"".basename($zipentryname)."\"" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".zip_entry_filesize($zipentry));
print $buffer;

Any idea? Thanks a lot in advance
Madhu August 26, 2008
Working Great

Thanks alot

Peter August 28, 2008
I'm using Win and IIS. The problem is that in binary files some empty characters are replaced by '\0' after being processed by the script. Text files work fine. Please help to make it work with binary files :) Thanks.
darrenewing [anti-spam] earthlink.net September 23, 2008
This code is completely awesome! THANK YOU! It turned literally hundreds of hours of failure into great success (mind you that's TWO YEARS after you originally uploaded it!) Cannot Thank You enough!
angelo September 30, 2008

after the download link i want to add dynamic data!
something like :
"download.php?f=" . $row_DetailRS1['downloadUri'];

everytime i try this i will get the error file not found or specify a filename.

how can i combine the string to dynamic mysql data?

please help
mr.amitabhsingh [anti-spam] gmail.com October 8, 2008
how can we use it because of i can't understood it variable also so please help me for undrstanding this script...
Amitabh Singh ....
amitabh October 8, 2008
i want this download code of php.
and i request to all person who has solved his problem through this code so please send me that related folder.
which can i deploy in wamp
please help me
reyn_rjc [anti-spam] yahoo.com October 11, 2008
Please help me on how to download files from my pc using the php scripts.
Sonali October 11, 2008
I m Sonali,hi 2 al
9880314583 Dis is my number Contact me i want some help from u frnds
scribzy October 23, 2008
Just what the doctor ordered thanks a lot and keep up the good work!
arasan [anti-spam] mahiti.org October 23, 2008
i've used this code but found that its slower than the ordinary download. Help me regarding this
mike [anti-spam] rowla.com October 26, 2008
Fantastic script thanks! If only just for forcing downloads!
patideepchand [anti-spam] gmail.com November 4, 2008
hi there i think it's a great script..now im using...it's works fine..but
while downloading suddenly 50% to 80% it's stoping and showing completed...i don't know why..could anyone plz help me
Irwan November 4, 2008
Awesome, great script.
i have been using this script since i found it. very easy to use it.
i changed the script using id_file and work perfect. thanks
anigart [anti-spam] hotmail.com November 7, 2008
Hi there,
I found that there is an issue with this (and many similar scripts): when using IE 7 or 8 beta2, and clicking cancel in the download box instead of downloading the file, it is not possible to navigate anymore on the site or download again (script seems to hang somewhere). Seems like it's a bug in IE since it works with Chrome and FireFox (Safari works once but will also hang when doing it the seconf time). I spent the last 2 days trying to workaround this, if anyone knows a solution it would be greatly appreciated.
November 8, 2008
First GRAT downloader THANKs
I have a question:
How I can define more directoryes?
THIS UNDER IS IMPOSSIBLE BECAUSE WE CAN'T DEFINE MORE $Var in define function... but I need somethink like this:

$kind = $_GET['kind'];

// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )
if ($kind=='mp3promo') {
} elseif ($kind=='mediaifle') {
} elseif ($kind=='RealAudio') {


Thanks 4 help
sssss [anti-spam] yahoo.com November 8, 2008
i got a earror

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /mounted-storage/home95c/sub001/sc1084824-EIBI/www/Files/****/download.php on line 81
Please specify file name for download.
anderson [anti-spam] unifal-mg.edu November 10, 2008
just pdf files are needed by me and
it works perfect! thank you a lot!
November 11, 2008
A great script - thanks very much. Worked first time after only minutes of setting the paths. Thanks for sharing open source.
fritze November 14, 2008
I have been looking for a script like this for months. This script is great!!
<b>THANK YOU<b>!!
Emiel Wieldraaijer November 22, 2008
Thanks nice script..

is it possible to redirect to a an url instead of displaying some simple text

// If hotlinking not allowed then make hackers think there are some server problems
&& (!isset($_SERVER['HTTP_REFERER']) || strpos(strtoupper($_SERVER['HTTP_REFERER']),strtoupper(ALLOWED_REFERRER)) === false)
) {
die("Not allowed. Please visit http://www.domain.com/error.");

Thanasis Delenikas November 23, 2008
Great script, thanks for sharing!
November 23, 2008
Use fpassthru($file_path)

It's a lot more efficient than using a manual read/write loop.
bhupindermalhotra [anti-spam] gmail.com November 25, 2008
nice script thanks
alam19bd [anti-spam] yahoo.com November 29, 2008
tnx tnx tnx a lot lot the author
it is grt job. i was searching for this scripts for a long time.

i am using this script here http://www.banglaeye.com/music/index.php?page=songs&album_id=2

tnx again

ram December 2, 2008
Hi All, I new to learn java script, please help me, I want download a file from another site through java script.

For example I need download this link http://dc95.4shared.com/download/22521633/a0584f5c/WroxProfessionalJavaScriptForWebDevelopers.pdf?tsid=20081202-061821-e0608f87
from my blog. what to do? send me the code pleeezeeee
ram December 2, 2008
my email id: ram.g@live.com. please help me inthis regard
sheetalbansal.acs [anti-spam] gmail.com December 4, 2008
Excellent!after changing some code it is working.Thanks
a [anti-spam] a.com December 16, 2008
It's really great
wiser X hellwap December 18, 2008
good work.
jules December 21, 2008
Thanks so much for this.Works like a charm for me and saved me a lot of headaches.
Merry Christmas
faltu [anti-spam] khola-janala.com December 22, 2008
Warning: opendir(/home/user/downloads/): failed to open dir: No such file or directory in /home/k/h/kholajanala/public_html/video/download.php on line 95

Warning: readdir(): supplied argument is not a valid Directory resource in /home/k/h/kholajanala/public_html/video/download.php on line 97
File does not exist. Make sure you specified correct file name.

I get this type of err. What can I do??
December 23, 2008
Thank you.
Very simple and it works!
Bogdan December 26, 2008
It worked from the first time! This is the best!
vsvnmurthy [anti-spam] rediffmai.com December 27, 2008
pkendre [anti-spam] adjility.com December 29, 2008
How can i download the file with extension '.xlsx'(excel document written in office 2007).

please help me, am stuckkkkkk
happy_v December 30, 2008
My first PHP script ever, and it works!

If I can figure out how to ask for a password, I'll be set for life.
salnazi [anti-spam] gmail.com January 5, 2009
Can you please guide me...how to use this script
sqamarabbas [anti-spam] yahoo.com January 5, 2009
i have uploaded some pdf files which can be download by your script at
it worked fine but today when i downloaded 1 pdf file on my computer i got this message"the file is damaged and could not be repared" i downloaded other pdf files but message was same . can you guid me?
dizsel74 [anti-spam] hotmail.com January 9, 2009
Gracias desde Mexico, muy chido codigo.
Thanks from Mexico, cool script.
vitalka9 January 10, 2009
nice :D
robert [anti-spam] 4elanclose.co.uk January 13, 2009
I'm using this script but for some reason an Excel file I have which is 131K is appearing a 262K when it downloads. I assumed this was to do with binary transfer but it seems not.

Any good ideas on what to test?
Sman January 19, 2009
is there any way to Crack someone else's coding?
Irina January 19, 2009
Brilliant once again!!!! thank you soooo much!
Abdul January 22, 2009
Warning: opendir(http://www.domain.com/images/): failed to open dir: not implemented in c:\appserv\www\download.php on line 97

Warning: readdir(): supplied argument is not a valid Directory resource in c:\appserv\www\download.php on line 99
File does not exist. Make sure you specified correct file name.

Thank you in Advance...
vishusahu [anti-spam] gmail.com January 29, 2009
whatever the files I am downloading using this script getting corrupted. I tried with .zip, .doc file. after download, the zip file is not extractable. doc file showing error on MSWORD. is this file required any kind of php setting or setting in apache configuration file?
Thankful January 30, 2009
Thanks so much for the script. Your script helped me in clearing a big road block in my project!
Cyndi C January 30, 2009
Perfect! Thanks!
Shoaib Khan February 2, 2009
Work great! I got what I want.
Sadanand, sadanandwarty [anti-spam] gmail.com February 7, 2009
hi, I want to download the "DROWNED OUT" VIDEO from the following website:


Plz tell me what I should do. I am a bit beginner in these script things....so, it would be nice if you explain the procedure in detail.

Thanks in advance
Sag-e-Attar Junaid Atari February 12, 2009
Its really nice man!

Thanks for uploading it!

Get me:
madhavpan [anti-spam] yahoo.com February 12, 2009
hi my name is madhav.

i used your smard file download script for the download links i works well and good for the files around of size 10 MB but it i am facing a problem when i was giving the links of zip folder of size more than 50MB. it is not downloading compleately its getting stop after downloading file of size 15 MB to 20 MB
can you give a solution for over come this problem.

rana_3098 [anti-spam] yahoo.com February 17, 2009
AVG anit virus which the file download.please about it. Sir
ouya.oulai [anti-spam] gmail.com February 20, 2009
If u want to use this script to download chinese or something encode with UTF-8, u can use urlencode() to encode file_name. (for IE download) (FF just use incov() )
By the way, Thanks for sharing!
February 23, 2009
gracias por el codigo, funciona perfecto!
skyblue February 25, 2009
Work really great!
It even can define open file type.
But user must remember to adjust the "BASE_DIR"
punjabi_guy01 [anti-spam] hotmail.com March 3, 2009
thankyou dear for nice script
March 3, 2009
i put your script on my site and it's awesome!
Mayur March 3, 2009
Good job. Thanks :)
luciaruban [anti-spam] yahoo.co.in March 5, 2009
i got one error,Please specify file name for download.
how to use this script? $file_path=? we must give the path? i put online/online.php it's correct? please reply me how it will be used?
gerard [anti-spam] k-bros.co.uk March 5, 2009
It would be great to get username and write to log, as my downloads are in a passwrod protected directory??
Goodboy March 6, 2009
Parse error: syntax error, unexpected T_IF, expecting ')' in /home/user/public_html/download.php on line 49

i am getting this error..please help me
madbrit March 11, 2009
Have set up the files and uploaded it to my server, but when i call up the script all that is shown on the page is "Please specify file name for download." can anybody help. thanks
kittu07_babu [anti-spam] yahoo.co.in March 14, 2009
I want a sample program to download a file in php in clientside using file concepts
kittu07_babu [anti-spam] yahoo.co.in March 16, 2009
I want a sample program how to download a file in php and description of the program
March 24, 2009
In my PHP application I get data from a mysql table and want to download the results to a .txt or .doc file. Can I use your script?

My SELECT statement: $sql = "Select email from table1";
sigbia [anti-spam] freemail.it March 28, 2009
i put the script on the home dir of my web server hosting

but when i call it http://www.digitalking.it/download.php?f=test.zip

it gives error, why?

in BASE_DIR i have specified:


the file to download is located at

Thanks a lot,
Simone Italy
sigbia [anti-spam] freemail.it March 30, 2009
Now is ok, i corrected it! thanks :-)

But i tried it works with "normal" html links, and not with the forms!

For example i have this form:

form NAME="form1" METHOD="LINK" ACTION="../download.php?f=test.zip"
input type="submit" name="button" value="Click!"

when i click the button it doesnt pass the link download.php?f=test.zip but http://www.digitalking.it/download.php?button=Click%21
so then it doesnt work!
naveen April 1, 2009
thank you very much your code works gr8...
clinton.brits [anti-spam] gmail.com April 1, 2009
I love the way it works but i'm having a problem in that when i run a test .exe file on my server, it runs perfectly but when you request the download using the php script and then run it it says that it's too big to put into memory but the file size is exactly the same. Is there something that needs to change besides the files location?
Angela April 2, 2009
Worked great. Exactly what I needed and saved myself hours trying to adapt something out of a book.
vijayitsoft [anti-spam] yahoo.co.in April 7, 2009

If you can mail me any school timetable generator code in php plzzzzzzz

Toby April 8, 2009
A lifesaver of a script, THANKS!
sebastiao April 8, 2009
Many many thanks.
It is working perfect.
I saved hours
jay April 9, 2009
hi, gr8 script! does anyone knows a way to limit downloads per ip? something like 20 allowed downloads per week for a given ip?
aakash.malik [anti-spam] gmail.com April 10, 2009
thanx, million of times. u've solved my biggest prob.
Victor April 12, 2009
This works great and saved me a headache. I know php and perl just enough hurt myself. Thanks a billion!
Mike April 14, 2009
This does not work correctly with sub directories. It finds the first file with the file name and uses that regardless if you specify the directory path with the file name.
paul [anti-spam] ultimate-it.com April 17, 2009
To use with sub directories:

Find [around line 86?]

if (!isset($_GET['f']) || empty($_GET['f'])) {
die("Please specify file name for download.");

and add this code BEFORE

//By FoxE : also get directory name
if (!isset($_GET['d']) || empty($_GET['d'])) {
die("Please specify directory name for download.");

//By FoxE : Now get directory name.
$dirname = basename($_GET['d']);

Your link should look like this:

<a href="http://path/to/script/download.php?d=directory&f=phptutorial.zip">Cool PHP Tutorial</a>
Dave April 17, 2009
Fantastic script! Thanks. Works like a charm. Took me a little bit of time to configure .. but that was after I realized I should actually read the directions! Thanks again.
mohamed April 22, 2009
how to download a file from the server
April 22, 2009
Kudos to the author! 5 minutes to implement and saved me a load of time!
Thanks!!! :D
gandila [anti-spam] ymail.com April 30, 2009
How to download it?
manikjan [anti-spam] hotmail.com April 30, 2009
Brilliant once again!!!! thank you soooo much!

Bunty April 30, 2009
you can limit download number or time file is available here

fengz May 1, 2009
i need a step by step guide on how to use this script!
many thanks!
Mamoun May 4, 2009
Thank you very much. It's really very useful.
G Natarajan Nallinattu Nallicherry May 5, 2009
Very Nice and fully satisfied
Yawny May 5, 2009
Thanks a bunch for this script. However IE 7 complains about the hotlinking feature. It looks to me like IE7 doesn't set the HTTP_REFERER variable? which would cause line 75 of download.php to fail. In any case, this forces me to have to disable hotlink blocking.
mumun May 6, 2009
oc thanks
Me May 6, 2009
Ok let me give u my situation. I have to design my site such that the members are sent the email of the download link (which must be secured offcourse) then I have to record how many times they have downloaded the File. Previously io will have the ID and Email of the user in the database and I have to increase the number of times they download by 1 each time they download the File. Does that makes sense?
May 8, 2009
thank you, saved a lot of time.
bitulet [anti-spam] gmail.com May 10, 2009
Its really a nice,unbeliveable and so much good. From Dhaka
mahfooz-ul-haq May 15, 2009
is it possible to download file from another server using your script,
for example if my files on abc.xyz.com and i want to accept download file request only from xyz.com...

what should i do in this case???
dannet May 16, 2009
Anybody knows how to rename a forced-download from an external source without using readfile() (and not saving the file on the local server)?
May 19, 2009
Fantastic code. Well done.
darshanalk May 21, 2009
This script is very good.
I tried it and it worked fine.
Thanks and well done.....
mukeshdak [anti-spam] gmail.com May 21, 2009
This script is just fantastic and working fine for me, Thanks a lot for your efforts
prakruthi May 22, 2009
hey nice code.. it really works.. superb :0
May 24, 2009
its great.thank you very much.
georgeleru [anti-spam] yahoo.com May 25, 2009
why i can't download files with char & in the filename? Also with + ?
not May 26, 2009
Yeah, thanks , still , I found this quite funny

$FILE_PATH = '';
find_file(base_dir, $fname, $FILE_PATH);

function find_file ($dirname, $fname, &$FILE_PATH) {


if (empty($FILE_PATH) && $file != '.' && $file != '..') {



tulle__92 [anti-spam] hotmail.com May 31, 2009
Please specify file name for download.
alan [anti-spam] fiebig.us June 4, 2009
First, thanks for the script!
Second, I've done a number of file uploads, which I then downloaded using your script. The filesize of the download is two bytes larger than the original and the uploaded file on the server. Only the file downloaded with the script is larger. Using a hex editor, I can see two tabs have been appended to the end of the file (0x09 0x09). Tested files were a zip, an rtf, and a pdf.

Any thoughts? Thanks!
forgetme June 4, 2009
Thanks for this useful script. It solves a lot of my critical problems. Hopefully you guys may share more useful scripts to Opensource, Developer community. :)
Ansory June 10, 2009
For resolve this problem, can you make some example what exacly we can to do zubrag?

real Example with you download folder and how to change on this Script.


colin [anti-spam] ubisan.com June 10, 2009
Great Script!

I'm looking for a variation on this that lets users leave their email address and in return, they get to download a file. Anybody got any ideas?
User June 14, 2009
Does this work for IE8? I haven't found any forced downloads via the header commands to work for IE8.
Grateful June 15, 2009
After searching and searching and trying multiple other scripts - SUCCESS!!! Thank you so much for your work! :D
jimmybbb June 18, 2009
Perfect! I was working on writing my own script when I ran across this page.. You just saved me a ton of testing and troubleshooting. And it worked on the first try. Thanks so much!
Tony June 18, 2009
Thanks, dude! Your script rocks!
June 19, 2009
iS it possible for downlaod file in remote server?

my downloaded files in the some other server eg:-www.downlaodfiles.com

my downlaod.php iscript in the www.mydomain.com

iS it possible for downlaod file from remote server ???????
ad June 19, 2009
Great script, thanks for posting this!

User, it works fine with IE8.

mithu June 29, 2009
great...thanku very much.....
woo July 2, 2009
there are somone ask and me too.
how to modify this script to works if file downloaded in other website?
Jonathan July 2, 2009
Great Script !
Thank you ! =)
July 3, 2009
it works well.
thank you very much for the script.
July 6, 2009
thanks ok???????
Paul July 6, 2009
Nice script! Thank you!!!!
Kalle H. V. July 12, 2009
I was searching for this script for 4 hours now. Works 100%, very very easy to install and make it fit with mysql logging or whatever you wish :)
Thank you. Keep it up.
newbiePhp July 13, 2009
Thanks leaps! It works great!!
July 15, 2009
How big is the largest file you tried? i tried 800+ mb and the problem seems to bee that the webserver first echoes everything into the website before the download begins
linux admin July 16, 2009
It depends on webserver configuration. Looks like your web server is setup to buffer data before making it available to client
jfrank July 18, 2009
Great script! Easiest to implement ive found.
jhill July 22, 2009
I've renamed the script to download_happnin.php because my site already has a download.php. This script works beautifully except when I test my site with IE5.5 Mac when IE 'puts up a dialog claiming the filename is 'download_happnin.php' and not the filename I'm downloading. If I do 'Save As...' this name is shown as well but the actual file downloaded is correct and has the right name. Weird. Here's hoping there aren't many IE 5.5 Mac users left out there.
Gracious July 24, 2009
Thanx, Zubrag.

These ungrateful creatures want something for free and then complain about it. Some dare to even grouse instead of making a polite request. Please keep up the good work and much success to you!
awaiskazimi [anti-spam] hotmail.com July 24, 2009
Great Script man, helped me too much... However, please specify in your file to change the BASE_DIR constant to the url of the file at server... anyway, thanks a lot...
viswanath July 29, 2009
thank you. my task was done very easily...
jayaprime [anti-spam] yahoo.com July 29, 2009
Worked immediately, excellent explanations, and even a little bit extra... yet most importantly... it worked. Thank you!
karthik August 5, 2009
great script
irshad August 5, 2009

Warning: opendir(http://localhost/filedownload/) [function.opendir]: failed to open dir: not implemented in C:\wamp\www\filedown\download.php on line 95

Warning: readdir(): supplied argument is not a valid Directory resource in C:\wamp\www\filedown\download.php on line 97
File does not exist. Make sure you specified correct file name.

I have tried a lot changed basedir ,added $dirname..but nothing works.
vil August 6, 2009
Thanks Zubrag, great job...
riazmohammedvk [anti-spam] gmail.com August 7, 2009
Gooooood script:) Thanks for it !!! :)

even i need a script that when user click the download links, it's should ask email address. Then the download will be started if the user email given !

Anyone have the script ))))
Please let me know !
Trinidex August 8, 2009
Thank you!
Works a treat for my needs!
vyas.dhruv [anti-spam] yahoo.com August 13, 2009
can u guide me for *.lrc format ??
August 16, 2009
great script
thanks a lot....
August 16, 2009
can u plz tell me how to set permissions???
Craig August 18, 2009
I can't believe some of the ungrateful comments!

Thanks dude, great script. Made some mods to write the log file to a database rather than the flat file, works a treat.

skillsongs [anti-spam] gmail.com August 26, 2009
Hi Sir I download you are fil,i have songs web site & i want hide my real links.but i dont knw php useing can you help me? i waiting u r reply sir
& i try to undastadnig this php code
Kabuloso August 28, 2009
Very good. Save my life! kkkkkkkkkk
djbahati [anti-spam] yahoo.co.uk August 31, 2009
Wow Wow thanks a lot for the interested script. I have been looking for this about 3 days.
Thanks once again and God bless you.
Nandaa [Kenya] September 2, 2009
I've just downloaded the script, am going to try it and get back to u ASAP. Great stuff man!
no-thx [anti-spam] mail.ru September 3, 2009
Thanks! You really helped me!
Kalessin September 4, 2009
This script was the first result on Google, and I had originally planned to take the bits I wanted and reuse them. However, it works in exactly the way I wanted right "out of the box"! Thanks very much.
edharries [anti-spam] gmail.com September 14, 2009
Hi, very please I found this, only having one issue with the log file.

In the download.php file, I have specified ../epk/downloads.log as the log file location, but when i go to the correct location there is nothing shown in the log file? I hope you can help
limyzhi [anti-spam] yahoo.com September 16, 2009
how come after i download a word file, the content of the word file can't show and it show a lot of symbol.
muzikis September 18, 2009
Awesome! Thanks!
rsmaha2007 [anti-spam] yahoo.com September 18, 2009
I have registered in fourm .I cant post . how to post?
vmsrodri [anti-spam] gmail.com September 22, 2009
It work's well for me. Tanks for the code.
I just added the new MIME types for office 2007. http://blogs.msdn.com/vsofficedeveloper/pages/Office-2007-Open-XML-MIME-Types.aspx
September 23, 2009
Great! Fast simple and powerfull
naseemkhanm [anti-spam] gmail.com September 29, 2009
More MIME (Multipurpose Internet Mail Extensions) is an Internet standard for describes message content types.
Check this link


October 2, 2009
Thank you.
milind_more1977 [anti-spam] rediffmail.com October 6, 2009
Really use full thank to all forum team
StresSdidri October 10, 2009
thank you very much
Jayesh Prajapati October 10, 2009
Really, Its Excellent job.
saliljain25 [anti-spam] gmail.com October 16, 2009
Hey this is a really great script but i'm facing a small problem, everytime I try to download a file , I end up with a file called download.php.jpg (for a file "SCAN.JPG")
Please help me!
Thank You
October 16, 2009
good script. It worked!!
Nina October 16, 2009
It is helpful!!!
r.bogartz [anti-spam] comcast.net October 16, 2009
Hi. This looks like a great script but I'm getting an error: Warning: opendir(/download/) [function.opendir]: failed to open dir: No such file or directory in (file location). Do I need to do more than just designate the base dir?

Thanks in advance.
October 20, 2009
This is a very good source code.

God bless.
denice October 21, 2009
What about download.php as a cronjob? Is it possible?
October 22, 2009
Great script! I was having a problem with my old script when using IE8.
October 24, 2009
When i click "download" button to download any docs from gmail, it wont open. insted it will ask to save. How to change settings to open any files before saving?
Peter October 26, 2009
How can I make the script download a file from a different server or a different web address? Is this possible?
Program Useless November 1, 2009
Can't get arround the "file not found problem no matter what I try... Gone looking for a program that WORKS!!!!
Ash November 3, 2009
I love this! Thanks so much for the script - works like a frikken bomb :) You rock!
cyclops4real [anti-spam] yahoo.com November 10, 2009
Warning: set_time_limit() has been disabled for security reasons in /home/www/downloads.awardspace.us/Downloadsafterwor/download.php on line 81
Please specify file name for download.
Mart November 10, 2009
This works great! Just took a couple of minutes to get the BASE_DIR set correctly - from then on worked perfectly.
eshanne November 14, 2009
hii nice script but i have a problem here.. i still can't make it done.. can you help me please..

please check this for me..

i tried so many times but i still can't make it done.. hope you can help me ..

i put my download.php at the /download/ folder..

renukar41 [anti-spam] gmail.com November 18, 2009
its giving error
Sx4 November 19, 2009
thanks. It works
mukul November 24, 2009
i works nice but anyone can download by giving direct link.i want that file should not download by pasting the link.
what can i do?
Abhay November 25, 2009
I tried to implement ur php scripts in my project, but it doesn't work.So, i have one question for u does ur script work on Zend Framework, coz my project is based on Zend Framework
cyclops4real [anti-spam] yahoo.com November 25, 2009
it works on local server xampp but when i uploaded to my webserver it doesnt work yet it php supported
Brad November 26, 2009
This is a great little program, thank you - exactly what I was after (something better for a web site than plonking in a href and leaving instructions to 'right click and save link'.

I was terrifically muddled - don't laugh - though when I thought the program was corrupting the files it was copying. I just couldn't work it out. The problem turned out to be my having various files of the same name in nested subdirectories ... and your find_file() deliberately looks in sub-directories for the named file?!?!?! Crazy. But after figuring that out it was all plain sailing, and a great widget to use.
balamuralimu [anti-spam] gmail.com November 28, 2009
i have some txt files in the folder and i need to add the files in to zip, i need the script for that
cyclops4real [anti-spam] yahoo.com November 29, 2009
its working on server but cut shut to 90 kb always
SISTEMCREATORS.COM November 29, 2009
Eric December 3, 2009
Great script, although I'm having this same problem with zip files arriving corrupt, can anyone shed any light on that situation?
December 3, 2009
I had used your code but while working on linux server after downloading the file the file has currupt....
Manish December 3, 2009

Thanx for such a beatiful script
jimmy December 6, 2009
Excellent script. Thanks for sharing with us!
junfublog.blogspot.com December 6, 2009
it works, thanks for your script.
nature_junejo [anti-spam] yahoo.com December 7, 2009
sir im also php developer i wana work with your group and want to join ur group
andyramdani [anti-spam] gmail.com December 8, 2009
Wow it's works dude!!!...Thx...beautiful and clean script...thx for share...waiting for ur next awesome script...^^v

Andi - Jakarta, Indonesia
December 8, 2009
How can we Download files like html and php dude? The thing is they open in browser.. And we dont get the save or open dialog box?
Download files like html and php December 8, 2009
set content type to "application/octet-stream" - it will open download dialog
n3w5.l3773r [anti-spam] /////no\\//spam\\\\virgin.net December 12, 2009
Works fabulously. One tip if you are having problems is to check and correctly set the permissions on the folders and log_file on the server.
sekarbright [anti-spam] gmail.com December 18, 2009
Really nice and simple to use...
Works good...
December 19, 2009
Nice script. I modified to suit my need. You can see it here and can download newest english movies:
dhilipsporty [anti-spam] gmail.com December 22, 2009
i am new webie somebody tell me full tutorial
December 23, 2009
It says
"Sorry, Internal Server Error"

when i put file size above 8mb.
How do i increase the download file size limit ?
suresh December 28, 2009
I get this error.

File does not exist. Make sure you specified correct file name.


this is the place i have download.php file. and the download files are in


now how should i give the path
jtootl [anti-spam] gmail.com December 29, 2009
All works fine, except the zip/rar files when you download and Extracting them they say they are corrupted
Vasanth07 December 30, 2009
How to Create Normal Download Page In HTML.(Files,Videos,Software,and some Files)
Rod January 1, 2010
Excelent, easy to setup and it works beautifully
polysync1 [anti-spam] googlemail.com January 7, 2010
hi there need some help,
What would be my BASE_DIR location if my files that i want downloading are stored in C:\xampp\htdocs\Dub\Uploads.?

ranjandeo [anti-spam] gmail.com January 10, 2010
Amazing !!!!!!!!!
Really great.
It is working perfectly as i needed.
Thanks a lot.
Mr.AnOiR January 10, 2010
Hello Guys ! It's really a cool script from you Zurbag! i was told how can i add and include date, file name, time of downloads,and that stiffs which you said in description of this script please help me to include that stuff on it and tell me how i will do that :) and thanx a lot for understanding me
Dave January 11, 2010
This script is awesome, I found a great host too: http://www.pacifichost.com you guys should check em out
j.weisberg [anti-spam] yahoo.com January 13, 2010
Has Anyone noticed any issues with this script functioning on ie 8?
bestarabic [anti-spam] sogetthis.com January 18, 2010
Thanx, I will try to add it on http://www.bestarabic.com
mflood [anti-spam] revolutionworld.com January 21, 2010
This just ends up downlaoding the php file itself. Any ideas?
January 24, 2010
I need a script for viewing images from other site in my page with hiding source, can &#305; use this script for it
James January 25, 2010
Excellent script works extremely well.. Just one question is there a possible way to add a login side to it in other words user has to enter username and password to download the file
protect download January 25, 2010
This forum post describes how to protect http://www.zubrag.com/forum/index.php/topic,182.0.html
You'll need http://www.zubrag.com/scripts/password-protect.php script for login/password prompt
bklyn2cali [anti-spam] gmail.com January 25, 2010
okay. i've read EVERY single post to this forum and i too am having problems with the install and use of this script.

I have files (on my site) that are stored in this manner:

i've set the define('BASE_DIR','download/');

(and i even tried putting user/download/)

on the page where i want to download, i have:

what am i doing incorrect?

i've tried about every combination (from others replies and suggestions on the board) and i'm having NO luck.

help please!
thank you.
pediatek February 2, 2010
I try to add it on
but the browser shows 'Internal server error. Please contact system administrator.'
February 7, 2010
Awesome script! Works like a charm!

Thank you!
admin [anti-spam] eziscript.com February 14, 2010
http://eziscript.com has released it's pagerank checker for free for you to download.
You can now create your own Google Pagerank Checker website and offer your visitors a way to check their website details for free, just like we have here.

How much does the Google PageRank Script cost?
Absolutely nothing, the script is absolutely FREE, for copyright removal.
ushadevidevaraji [anti-spam] gmail.com February 17, 2010
Is it possible to integrate with cloudfiles(Mosso)
February 23, 2010
alphyjuma [anti-spam] yahoo.com February 23, 2010
This is a nice code for me. Its great.
From KDU we use the yahoo version
m.zsemlye [anti-spam] koenigfrankstahl.sk March 2, 2010
I cant download a file with name, that have a + in it.
How can it be resolved ?

PS: Script is great, I use it for finding in thousands files.
dev March 3, 2010
thanx working fine
Jason Ward March 6, 2010
Tossed in a few tweaks to fit my situation and this works great! Thanks for taking the time to share your code. =)
support [anti-spam] borche.org March 7, 2010

Warning: opendir(/home/user/downloads/) [function.opendir]: failed to open dir: No such file or directory in /home/borche/public_html/musicdotorg/download.php on line 95

Warning: readdir(): supplied argument is not a valid Directory resource in /home/borche/public_html/musicdotorg/download.php on line 97
File does not exist. Make sure you specified correct file name.
preni_ak [anti-spam] yahoo.in March 11, 2010
Slow Coach March 13, 2010
Can someone help me!

How to make my download page(downloadpage.html) to expire in a particular of the time to my subscribers.
shaan.gtx [anti-spam] gmail.com March 16, 2010
hi there, i have downloaded a zip file size 568mb. but its named "downlad.zip" i cant open it. how do i convert that back to zip?
shaan.gtx [anti-spam] gmail.com March 16, 2010
hi there, i have downloaded a zip file size 568mb. but its named "downlad.PHP" i cant open it. how do i convert that back to zip?
ashok March 17, 2010

i m learning PHP. i need PHP related reference web sites.
Easy Download Any File Type March 19, 2010

This is a wonderful download script.
Create a folder called "fileDownload" save this script as dl.php then place in the fileDownload folder on your server place anything you want to download in this folder then add this tag on any web page to download any file type.

<a href="http://www.yourdomain.com/fileDownload/dl.php?filename=YourFiletoDownload.mp3">Your Text</a>
That script March 19, 2010

// File Download Script
// by James Warkentin

// This script is provided without warrenty of any kind, nor may the author be held liable for
// for any problems which arise as a result of the use of this script.

// Modify this line to indicate the location of the files you want people to be able to download
// This path must not contain a trailing slash. ie. /temp/files/download

$download_path = $_SERVER['DOCUMENT_ROOT'] . "/fileDownload";

add next pat here
add part 3 March 19, 2010

/* ###################################################################################*/
/* ###################################################################################*/

$filename = $_GET['filename'];

// Detect missing filename
if(!$filename) die("I'm sorry, you must specify a file name to download.");

// Make sure we can't download files above the current directory location.
if(eregi("\.\.", $filename)) die("I'm sorry, you may not download that file.");
$file = str_replace("..", "", $filename);

part 4 hear
part 4 March 19, 2010
// Make sure we can't download .ht control files.
if(eregi("\.ht.+", $filename)) die("I'm sorry, you may not download that file.");

// Combine the download path and the filename to create the full path to the file.
$file = "$download_path/$file";

// Test to ensure that the file exists.
if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist.");

// Extract the type of file which will be sent to the browser as a header
$type = filetype($file);

// Get a date and timestamp
$today = date("F j, Y, g:i a");
$time = time();

// Send file headers
header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename");
header('Pragma: no-cache');
header('Expires: 0');

// Send the file contents.

garygibbons [anti-spam] pugetcustompc.com March 22, 2010
Trying to get this to work correctly on IIS 7 using VS 2008 and asp.net development server. PHP is enabled on IIS. So far the download.php file opens without calling the desired file.

I'm calling the file like this:
<a href="php/download.php?f=PriceList.pdf">Price List</a>
The download.php file resides in the root directory as php/download.php.

Any suggestions as to how to get this working would be helpful!
March 22, 2010
Nice one!
IrFan_1933 March 25, 2010
Its worksssssssss ...
Very niceeeeeeeeeeeeeeeeeeeeeee ...
Thxxxxxxxxxxxxxx ..
Vincent March 25, 2010
Hi zubrag, I am new to php and I have done all exactly that you mentioned in the site, but the output I get is some asci charcters on the page. I am not sure how to fix - can you help? I need this to help download xls and pdf files from server site.

dj arcanus March 26, 2010
thank you so much.

my script doesn't work anymore. it fails part way through the download.

i just dropped your script in place of mine and it works!

thanks so much for doing this. :)
March 31, 2010
is it possible to open the files in another tab or window
April 1, 2010
Nice Script. Just a note: you need to put the full path starting with the / as the hard drive root for it to work. Nice script! works well at http://theocas.net/
Kadek April 1, 2010
Thanks so much :D
brettjuilly [anti-spam] hotmail.com April 2, 2010
Excellent code! Needs error trapping though. It's really simple. To redirect to a different page when there's an error, use this:
die("<meta http-equiv='refresh' content='0;url=download_fail.php");

Of course replace my example url (download_fail.php) with your own.

In the zubrag.com code, 4 of the die statements have text in their parentheses: die("Please specify file name for download blah blah blah."). Two of the die statements do not have text in their parentheses: die(). Only use the "meta http-equiv" in place of the die statements that DO have text in their parentheses.

(Sorry, zubrag, I know you said not to alter that code. But it really needed custom error trapping!)
Michael April 7, 2010
Awesome! Thanks
April 9, 2010
Oops... i messed up some text above. here is the problem

i still couldnt make it to work. i did like this.
i created a folder on my server called "FileDownload".
in this folder i dropped zubrag's script(download.php), my html page and a sample pdf file.
i changed the path in the script like this...
line:22 define('BASE_DIR','/home/user/downloads/'); as
define('BASE_DIR', '/fileDownload/');

my html:
<a href="download.php?f=test.pdf">download this</a>

i got this error:
Not Found
The requested URL /fileDownload/download.php was not found on this server.
rams April 9, 2010
alright! i've resolved my above problem. i was wrong in path specification. thanks again to --zubrag-- and --James Warkentin--
roddersf1 [anti-spam] yahoo.co.uk April 11, 2010
Thanks for writing this very useful script.
I am having problems.
This is the file I want to download:

On my homepage http://www.thebreadcrumbtrail.org I have the "Cool PHP Tutorial" link. But when I click it I get the following:


Any ideas?

I put define('BASE_DIR','/gallery2/g2data/albums/breadcrumb_info/'); in the download.php

falgunidattani [anti-spam] yahoo.com April 15, 2010
above solution has resolved my many problems..thanks to the script writer..
londres9b [anti-spam] gmail.com April 18, 2010
It's great!!

ikem April 26, 2010
Hi...used this script but consistently giving the message 'Please specify file name for download'.
Pl suggest what to do.
drew_afterlife [anti-spam] yahoo.co.id April 27, 2010
Uruk May 1, 2010
Grazie! Ottimo script!
kutub May 10, 2010
This works great for downloading flv files but how can i use this script with .flv files to play in the SWF player?

Basically i am trying to hide the real path of the ".flv" file.

Any inputs?
gris May 11, 2010
If i need a download.php in a directory accessible by the webserver (say under public_html) i simply use:

<?php include("/home/somewhere/tools/password_protect.php");

nandigam.ramesh [anti-spam] gmail.com May 11, 2010
i need help:
i need to my local system having pdf file need to upload on remote server thru http,
in this above http - remote server ip and that floder attachments --> need to copy my local system c:\upload\sample.pdf.
using corol, php, javascript, any language, but here no database using mysql we can't create table concept here.
marc May 13, 2010
fun-tastic and recommended !

but, if i want, say, call a document in a
iframe, and obfuscate the source ?

maybe at a glance you could save me
hours of headache !!! tahnk you
Buni May 14, 2010
Please Help Me,

The download works perfectly but the zip archive not appear to be a valid archive.
With another file types works fine, but with zip not.
I receive this error:
End-of-central-directory signature not found. Either this file is not a Zip file, or it constitutes one disk of a multi-part Zip file.

Please Help Me!
Sorry for bad english.
manan May 15, 2010
it is very nice code for download.
mekoblink May 16, 2010
works for me.
the url i use
once used and download starts it changed to in browser
so i can email the first link in an email.
WooT thanks
debsinha3 [anti-spam] gmail.com May 18, 2010

i am using your script;but download resume not supported (using FDM,FDA etc.)
please help me
EboNiTTo May 21, 2010
the last script its awesome Thanks
MARC May 24, 2010
Is there anyone who can give me a code in php that can create a page file to redirect so many data's in one page to onother?.. Because I wanted to make my page look simple rather than scrolling down and up my page.. Thank You!..
May 24, 2010
Works wonders! I wish you had placed your name in the comments, but whoever you are, excellent work!
Duleep May 26, 2010
$file = @fopen($file_path,"rb");
if ($file) {
//echo "fopen";
while(!feof($file)) {
print(fread($file, 1024*8));
if (connection_status()!=0) {
some thing wrong this code i can't understand error that code part show unread character in web page and stuck page
anybody know reason plz reply
noreply [anti-spam] email-contacts.com May 27, 2010
Works excellent. Thank you very much!
dakil [anti-spam] hotmail.com May 31, 2010
BRO, i reli love u. excellent work!
powerspam [anti-spam] pow.de June 2, 2010
ed.wop@mapsrewop | spread! thelt
Yuehan June 9, 2010
You said:
"Is there anyone who can give me a code in php that can create a page file to redirect so many data's in one page to onother?.. Because I wanted to make my page look simple rather than scrolling down and up my page.. Thank You!.. "

Maybe I can help, but I'm not sure what you mean; can you explain?
upulsuresh [anti-spam] gmail.com June 12, 2010
Thank a lot
Can I know possibility of download text file ,.js file and other script files

Thank you
June 14, 2010
Hmm video files shows up as text in the browser instead of downloading in IE8, but downloading fine with mozilla... guess its a setting somewhere in IE8.
padt June 16, 2010
Please note that this script has this problem: http://www.milw0rm.com/exploits/8567
June 16, 2010
Updated to version 1.31 and has a fix for that problem
Theodore June 18, 2010
Thanks for the scrip Zubrag. However, I can't find the downloads.log file anywhere...

I have the following settings in download.php


// log downloads? true/false

// log file name

The files to be downloaded are in my /public_html/download/
The download.php script is in
and the html file with the reference in it is in

and as follows

<a href="http://www.website.com.au/download/download.php?f=filename.doc">filename</a>

Permissions on all the folders/directories is 777 ie rwx for user/group/others
The file downloads ok, however, I can;t find the log file ??? It looks like I'm the only one having this problem in all this time ... doh

Please help

June 21, 2010
Cool stuff thank you very much!
Theodore June 21, 2010
No problem with the downloads.log file. It's there.

Thanks for the script Zubrag and keep up the good work!

Any possibility of linking (or modifying) this script with your password-protect.php script? So that we can identify which user is downloading the file rather than the IP address? This would take the script to a new level!
Pardon my php experience if not possible.

Once again, thanks Zubrag!
Lucas June 21, 2010
When i click on the link i get this:

Warning: opendir(/1/) [function.opendir]: failed to open dir: No error in C:\*****\htdocs\dl\download.php on line 98

Warning: readdir(): supplied argument is not a valid Directory resource in C:\*****\htdocs\dl\download.php on line 100
File does not exist. Make sure you specified correct file name.

I ***'d out the folder name because it is personal. But you get the idea, any ideas, i changed the home folder and i put the file into the folder and i changed the link in the page. Any ideas? Lucas
revolution32 [anti-spam] gmail.com June 21, 2010
thanks for tutorial , I will create to my web client.
please share another trick.
Binxalot June 22, 2010
There is one thing you need to add to this script if you are getting corrupted .Zips or .exe when downloading large files, look for the line:
print(fread($file, 1024*8));
and add an @ to the front of fread like so:
print(@fread($file, 1024*8));
This will supress any errors given by fread() which gets written to the zip file or exe once the function finishes. Without it any error literally get written out in plain text in to the zip / pdf / exe file itself thus corrupting it.
avijit.bkp [anti-spam] gmail.com June 23, 2010
File does not exist. Make sure you specified correct file name.
kotakorange June 25, 2010
It's work great for single file. But how to download multiple files?
amin_al85 [anti-spam] yahoo.com June 28, 2010
I need a very sftyer
July 3, 2010
thank for your code.
July 6, 2010
My search ended today
jvkampen [anti-spam] interneeds.net July 14, 2010
Hi there, who has an answer for my problem. I installed the download.php as described and everything works great even the download log. Only, when I either download the zip folder or try to open it before download, it gives me this error reading: The Compressed (zipped) Folder is invalid or corrupted. Still, if I open the same zip folder from within ftp is works just fine. I appreciate anyone who has the knowledge with php scripting to help me out with an answer to correct this problem, JohnvK
July 14, 2010
Thanks a lot, this script just helped me solve a complex problem, bent it to fit my needs, but awesome script.
July 14, 2010
i keep getting this error when i test it on the web

Warning: opendir(downloads) [function.opendir]: failed to open dir: No such file or directory in /home/mindzmuzic/domains/mindzmuzic.com/public_html/downloads/download.php on line 99

Warning: readdir(): supplied argument is not a valid Directory resource in /home/mindzmuzic/domains/mindzmuzic.com/public_html/downloads/download.php on line 101
File does not exist. Make sure you specified correct file name.

but when i test it locally it works! i dont understad what i did wrong
iwst.me [anti-spam] gmail.com July 14, 2010
i want to give a url into the code, and download all the image from this given url (website).
how it is possible... please help me.
regards to all
umesh.chandra27 [anti-spam] gmail.com July 16, 2010
how to use download file
programmer July 26, 2010
thanks very much
it's really nice work
azee0071 [anti-spam] yahoo.com July 29, 2010
how this script is work tell me in detail and step by step in eazy way because i have not any knowledge about scripts. thanks
file downloader user July 29, 2010
Absolutely fantastic! File downloader super easy to setup and works great. thank you!!
mail2radhakrishnan [anti-spam] gmail.com July 29, 2010
I am dynamically creating a text file in my server and then passing a file name to this downloader.
How to re-direct to original page after downloading?
Thanks in advance
July 31, 2010
hi zubrag. i am wondering why do you read off chunks of bytes from the file and then flush it, until eof. Why can't one just use a readfile(). Whats the advantage or reason to do it your way?
shakrishnan78 [anti-spam] gmail.com August 2, 2010
I want to pull more than 10,000 vox files from a path by datewise if any free exe file avaialble
chirwa August 5, 2010

the script wrked very well withou even a single promblem. Thanks so much
Kaypee August 5, 2010
Works great! Thanks!
vg.priya [anti-spam] rediffmail.com August 6, 2010
Until downloading The code works fine. but after downloading the downloaded file cannot be read. I tried to download a jpg image. The image is not broken and has no problem. then why it is giving error? The image cannot be viewed........ plz help me.....
harianil [anti-spam] gmail.com August 12, 2010
Can you help me with my errors. See the output here
Sagar August 12, 2010
Thanx alot..........
it is superb.
nagy.marcell [anti-spam] citromail.hu August 13, 2010
Thank you. God. :)
Bavithra August 16, 2010
How to save the downloading files in the specified path according to the user wish
priyalatha.php [anti-spam] gmail.com August 16, 2010
i need how to install and work with drupal.send me the simple way of instructions .plz do it, its need full for me..

regards: priya
touclou [anti-spam] gmail.com August 23, 2010
pleas how the work can same body exple me goood and what can i change in the scripte
pleace contacte me touclou@gmail.com thx a lottfe
August 23, 2010
Thanks, works like a charm
liberty2death [anti-spam] yahoo.com August 24, 2010
Hellp me download free music
goolug [anti-spam] gmail.com August 27, 2010
Thank you ever so much!
I've spent an hour trying to get this to work getting that getdir error.
Finally I realized that I was too stupid not to change the code below the "DO NOT CHANGE BELOW" point.

So for all who're having problems with this directory stuff, on top of the code, where it says:
// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )
// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )

And make sure you have such folder on your server and that you have the file named correctly in there.

Works like a charm!

Thank you ever so much. Titanic piece of code!
Kurt September 1, 2010
We've been using this for over a year and works great! Thank you.

Lately, we've been adding a few mime-types to the stack and thought others may find this helpful.

// documents
'pdf' => 'application/pdf',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xls' => 'application/vnd.ms-excel',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'ppt' => 'application/vnd.ms-powerpoint',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
guna_wanlie [anti-spam] yahoo.com September 3, 2010
Perfect! I just put the script to my intranet and it works ! Thanks you.
preshmnisi [anti-spam] gmail.com September 14, 2010
I have been using ur script, its great and neat, but everyime i download, it says cant determine file type, whhat does that man? Pls help me
September 15, 2010

Is there any open source script to "Open multiple URLs" at one click?

I am looking for this script for my web sites:

Thanks in advance!
rk19chap [anti-spam] gmail.com September 20, 2010
in my college,there is a restriction on downloading. maximum file size of 10 mb we can download. is there any solution for this problem??????
johnwick7 [anti-spam] gmail.com September 21, 2010
how to modify the script for wordpress?

mkingston [anti-spam] weblinesys.com September 21, 2010
I've been testing this script and I'm having a problem. I've created a pdf file, which opens fine in Adobe Reader when you double click on it. So, I entered the address to run download.php?f=filename.php. The problem is it downloads a file of zero length. There are no error msgs in the log, only an entry indicating the file was downloaded.

mkingston September 21, 2010
Sorry, I misspelled the filename. It is actually filename.pdf.
vikas5misra [anti-spam] gmail.com September 24, 2010
i am new to php. i knew java and wanna give an option in our website to download file of type pdf.how should i use it
hi September 27, 2010
harianil [anti-spam] gmail.com
August 11, 2010
Can you help me with my errors. See the output here
'JPG' => 'image/jpeg'
questionmenot [anti-spam] gmail.com September 29, 2010
keep getting this error
File does not exist. Make sure you specified correct file name.

define('ALLOWED_REFERRER', '');

// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )

// log downloads? true/false

// log file name

please help
neerajnitw3 [anti-spam] gmail.com September 29, 2010
thanks ......very good script
Satheesh October 2, 2010
This is working good. Great job.
Thank you.
manofgod1993 [anti-spam] gmail.com October 3, 2010
Great script!! One problem.. When i try to download powerpoints, it downloads but when i try to open it it says it is corrupt.. know why?
October 5, 2010
I used this script.Please let me know what are the areas I should edit and where I have to put download.php file
david October 7, 2010
this script works great with my new host, you guys should check them out: http://www.pacifichost.com
Tahseen October 8, 2010
this script not work with safe mode php how can i run this script with sade mode php ?
Deepesh October 9, 2010
Hi zubrag,
Thanks for the great code, but i want that script which downloads to specific location on the client side...

Hope you'll post that....
Thanks again,
another user October 14, 2010
October 19, 2010
Thanks Zubrag, works great.
October 20, 2010
Thanks a lot..
I hav used it in my site.
enr.bisio [anti-spam] gmail.com October 28, 2010
I need help to understand how Can I use this script step by step to download file ...I need some examples to learn how to use this script...if i want to download a file from a website what have I to typed on my browser to download that file ?
October 28, 2010
It works.... Thanks zubarg
shrejas October 28, 2010
great code.... thanks a lot
Konstantin November 3, 2010
Works great! i install it on my project page here http://arec.com.ua/eng/projects.php
rs1102 [anti-spam] gmail.com November 5, 2010
I am new to php and having this "Please specify file name for download" issue. How to specify the file name? Please help?
November 5, 2010
Great script - tested with IE6 and up, Firefox, Safari (yuk) Chrome and Opera - all work great. Only change needed for 1&1 - had to specify the full path of the download folder. Thanks
Thomas November 6, 2010
Great script. Saved me hours of putting one together myself. Thanks so much.
debashis1979 [anti-spam] gmail.com November 7, 2010
This is a Great Script, The problems as faced by you till now have a Quick resolve

problem 1. set_time_limit(0); If this creates a Problem, just comment it

Problem 2.File does not exist. Make sure you specified correct file name.

This is because the $file_path is null, give a value of any of the files in your directory and the script works great

problem 3 : $dir = opendir($dirname);

This is because the BASE_DIR is not defined, if you are getting an error , copy the directory path in full and place it in the define BASE_DIR section , like /var/www/vhosts/sitename/httpdocs/foldername/

and it will work great

I faced a lot of problem at the start, but the outcome is great .. Will be very grateful to the GUY who posted this thread and also the source code.

dolbyajish [anti-spam] yahoo.co.in November 12, 2010
Hi zubrag,
I have a problem when this script is running in localhost - "Please specify file name for download". Please help me.
ASU Service November 18, 2010
Worked great for me ... Thank You!
Nick November 23, 2010
Hi, Works great for most things. Having trouble with mov. It sees the video/quicktime MIME, but quicktime is still choking on the downloaded file (it is not a file that quicktime understands). File works fine on the server.

syam22587 [anti-spam] gmail.com November 24, 2010
this is working gr8...
wayne December 2, 2010
I used the previous version for about a year but it failed on the new ubuntu 10.04 server we have. The failure was that mime types were not being recognised correctly - so i upgraded to the latestt 1.31 version and all is now good :-)

Thanks zubrag
December 8, 2010
how to use download.php
Michael December 15, 2010
Kudos! nicely done!
Adnan khan December 15, 2010
Awesome script buddy.... Good work.....
You rock....:)
pavlovic.industrial [anti-spam] gmail.com December 18, 2010

I get warning - File does not exist. Make sure you specified correct file name.

I am not an PHP expert so I am not sure what do you mean with your answer -

"This is because the $file_path is null, give a value of any of the files in your directory and the script works great"
bijoyfpi74 [anti-spam] yahoo.com December 19, 2010
I get warning - File does not exist. Make sure you specified correct file name.

I am not an PHP expert so I am not sure what do you mean with your answer -

"This is because the $file_path is null, give a value of any of the files in your directory and the script works great"
maxtemp [anti-spam] libero.it December 31, 2010
wy do i get
Parse error: syntax error, unexpected T_IF in mysite/
on the line if (!isset($_GET['fc']) || empty($_GET['fc'])) {$asfname = $fname;}
please help
steve January 12, 2011
I was having trouble using this code to download zip files, in which the file would unzip with a CPGZ extension. I was able to eliminate this problem by adding ob_clean() and flush() after the headers were set.

// set headers
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $mtype");
header("Content-Disposition: attachment; filename=\"$asfname\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);

muhammaddanish321 [anti-spam] gmail.com January 14, 2011
it not works in server
jackdvd002 [anti-spam] gmail.com January 21, 2011
how to get pdf file in php?.....<a href="http://www.aboutwebsite.net">SRV</a>
eragon.hack January 26, 2011
thank youuu !! Working fine !!
Sirsendu Chakraborty January 30, 2011
This has worked for me, great!!!
joe [anti-spam] technologyconnectioninc.com January 31, 2011
All that im trying to do is connect the name that is in the database to a pdf on the hard drive. How would you do this?
pribanic.luka [anti-spam] gmail.com February 2, 2011
I was wondering, does this script have any problems when user is downloading large files, like 4-5GB. Most scripts Ive tried so far broke before 2GB.. so Id really like to know if youve tried that. Ive got a site where Im hosting large videos (about the size of single layer DVD), and Im looking for a solution. So far I had zero luck
iveta February 3, 2011
Many thankx, works great for me .. :)
epicCreations February 5, 2011
Dude, I love you. This is magnificant. I altered it to fit my CMS and log via SQL. Seriously, I love you man. Thank you so much.
subburaj784 [anti-spam] gmail.com February 11, 2011
i want mac themes
February 13, 2011
Great script! Easy and effective. Thank you!
February 15, 2011
all i get is this " Please specify file name for download. " where am i going wrong?
Rock February 22, 2011
I'm having trouble with setting up a download page that draws from a pool (folder) of various files to download dependent on purchase selection. How do I write a php script to know what was purchased and automatically grab the file selected by purchase?

Can you help me out with this or have a script laying around for this purpose?
milomir February 26, 2011
doesn't work with opera mobile (symbian) and opera mini (java),
opera mobile starts download but seams like script doesn't transfer data, on opera mini page is reloaded, no file download dialog..

any solution?
chandan March 1, 2011
hey your code is good.
thanks for this
kamui March 2, 2011
your work is awesome!
March 4, 2011
works like a dream!!! eezy peezy!!!
monitor March 14, 2011
alex_ccue [anti-spam] hotmail.com March 23, 2011
Thanks for your hard work.
but the file download cannot open or have error with the file.
Any suggestion on it ?
egalvao [anti-spam] gmail.com March 25, 2011
Just fantastic! Saved my week!
h.shoja [anti-spam] hotmail.com April 1, 2011
it worked true, but there was a problem.
instead of opening the savedialog,the browser opens the contents of file.
h.shoja [anti-spam] hotmail.com April 1, 2011
if found this code

that works true.
// your file to upload
$file = 'pp.pdf';
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: application/pdf");
// tell file size
header('Content-length: '.filesize($file));
// set file name
header('Content-disposition: attachment; filename='.basename($file));
// Exit script. So that no useless data is output-ed.
bajpai.innodata [anti-spam] gmail.com April 11, 2011
i am using joomla for creating the website
i want the feature that when i enter some code like numbers then after ppt is downloaded after making payment for downloding
nickwalks [anti-spam] hotmail.com April 11, 2011
Thanks for the script Zubrag!
I had trouble setting the base directory, but after trial and error this worked for me:

abhi0101 [anti-spam] yahoo.com April 12, 2011
My downlo forlder:- http://khojdunia.com/archint4/admin/upload/
Internal Server Error
2> I have kepy download.php in upload folder where my files are.
3> My html path <a href="http://khojdunia.com/archint4/admin/upload/download.php?f=<? echo $res['file'];?>">Download</a>
4> path in download.php define('BASE_DIR','/home/khojduni/public_html/archint4/admin/upload/');

it sayd internal server error where i am mistaking this is working in login not in my server plz plz help
April 13, 2011
It's really nice and perfect working code...

thanks honey
shiroj.sha [anti-spam] gmail.com April 14, 2011
I already download your Script.But the script is not working proper.Please give me the instruction for this script.
G1L April 14, 2011
Excleent job congratulations
manish.kumbhkar [anti-spam] yahoo.com April 15, 2011
how can i download video as fast as fast of large size up to 700 mb
colin [anti-spam] empem.org April 17, 2011
Great. Worked first time! Thank you
marus.david01 [anti-spam] gmail.com April 23, 2011
Indeed a very good read! Very informative post with pretty good insight on all aspects of the topic! Will keep visiting in future too!
michael.klem [anti-spam] gmail.com April 26, 2011
Thank! Worked perfectly!
Umamaheswari April 29, 2011
Thanks a lot! Works Great.
rafeeq [anti-spam] gmx.com April 29, 2011
download is fine with IE and Firefox , but i can't download mp3 file on mobile
download 99.9% after Unable to download anybody help please

i really like this code
Oswaldo Gmez April 30, 2011
SUPERB! Worked like a charm, and I solved in a snap what other took two days work to develop and test. Thank you very much!!
tom April 30, 2011
Thanks for the script but I cannot get the logs function to work. Folders are all set to be writeable, but no information is added to the log file itself.
Anybody got an idea?

digital_es [anti-spam] ymail.com May 9, 2011
Thanx, i new in PHP,
these very helpfull codes,
lots of thanx,
one thing when download big file (above 100MB) very slow appear save or open dialogebox
what happen????????
May 12, 2011
Thanks, this was exactly what I was looking for. I was easy to figure out and implement
Surya June 1, 2011
Thanks for your code.It's working nice. keep it up
Mohamed June 2, 2011
Thanks alot for this code :D
Its works 100%
webmaster [anti-spam] ukwebpromotions.com June 4, 2011
Great php script but it doesnt seem to work on https enabled websites, although i may be wrong on this and its something that needs altering in the script.
When i type in https://mysite.com in define('ALLOWED_REFERRER', section it throws an error.

Any suggestions please.

bharattalaviya1990 [anti-spam] yahoo.com June 25, 2011
well done!
bharat [anti-spam] talaviya.com June 25, 2011
To define base directory,
Instead of absolute path and relative path, it is the best to use

prashantguru31 [anti-spam] gmail.com June 26, 2011
Nice Script
C0nw0nk [anti-spam] hotmail.co.uk July 4, 2011
How can you define more than one directory for files to be pulled from ?


can anyone help me out :D ?
Adaptor July 12, 2011
Thanks for the script. Solved my problem in minutes.

For anyone that can't find the actual directory on the server:on a
Use <?php echo $_SERVER["DOCUMENT_ROOT"]; ?> to get the path.
July 19, 2011
i'm the beginer for php. i download the download.php.. i have the error msg
Please specify file name for download
Luc July 19, 2011
Is there a size-limit? Can a 2GB file been downloaded?
chintanhingrajiya [anti-spam] gmail.com July 25, 2011
this script is best for pc users but in mobile it seems fail some download please help me
i want to use this script in mobile

thanks advance.
Praful Rajput July 27, 2011
Very Cool!!
August 11, 2011
Working great. Many thanks Zubrag.

-Usha Malini
Colombo - 13
super2power1 [anti-spam] gmail.com August 11, 2011
zubrag when i use this script download file open instead of download..!
rpalanivel83 [anti-spam] gmail.com August 13, 2011

Its a good code but the log should not when i cancel the download. how to handle this?

Thanks in advance, Pal
joemackay [anti-spam] gmail.com August 15, 2011
Thank you so much, worked gr8
Zalak August 15, 2011
I got this but after finishing the download i want my page to be in the original position but it doesn't do that. data on the page getting blank. Any Solution for this ?
punky_funky_nebunatica [anti-spam] yahoo.com August 24, 2011
i download it and its not working please someone help me i relly need this program!!
August 26, 2011
Mustafa August 31, 2011
@punky_funky_nebunatica, what is the problem? Because, I just tested and the script is just working fine.
September 13, 2011
Works great I wanted to say thanks.
September 21, 2011
this chappy Zubrag obviously wrote this script to impress his fellow hackheads. For those of you who wants a script that actually works with simple and well written instruction - that's about 99% of you that left messages here - check this out http://www.warkensoft.com/2006/09/file-download-script/
marus.david01 [anti-spam] gmail.com September 27, 2011
I just stumbled upon your blog after reading your blog posts wanted to say thanks.i highly appreciate the blogger for doing this effort.

fogh September 27, 2011
hey.. great but, If I use firefox the file i download does not have a filetype???
anilyadav16790 [anti-spam] gmail.com October 7, 2011
i m getting the error "Please specify file name for download."
can any one help me
ezep.linux [anti-spam] gmail.com October 13, 2011
Great script, just what I was looking for,and logging using a db is a pretty good idea too ;).

Thanks !
duonghc [anti-spam] gmail.com October 14, 2011

g.ch.alex [anti-spam] gmail.com October 14, 2011
Thanks! I was only looking for a tutotial, but it's 100 times better! You are good ;)
law October 15, 2011
tnx a lot.. super!
borut.tomazin [anti-spam] gmail.com October 16, 2011
I have a problem with IE. Don't know why but SERVER variable $_SERVER['HTTP_REFERER'] is not set. On all other major browser this is not a problem. How can I avoid this?

jonathan young October 20, 2011
this code is full of awesome. it just works. thank you so much! I am going to reverse engineer the whole thing and get a master class on file gets. thank you , thank you , thank you!
rubbell2u [anti-spam] gmail.com October 25, 2011
i love it
October 28, 2011
Thank you thank you.
NeoLegends November 7, 2011
It works but the files are corrupted. I have a 000webhost.com free-server.
vonvatanakoudom [anti-spam] gmail.com November 8, 2011
can i use this script for download file in Wordpress?
Malavika November 14, 2011
I am trying to download file from the website. Please can anyone specify where I can enter the url of the website in the script.
farrell November 14, 2011
where you want your download link appear for users
tomassevich [anti-spam] mail.ru November 18, 2011
Thank you man from the RUSSIA!!!
arry November 26, 2011
sorry i can't the result is Please specify file name for download.
why,., can you help me all???
Ishara November 28, 2011
Thanx 4d product
November 30, 2011
i want to add a exe file on my on web page . i should be downloaded with one click without going to any other site ., where should i upload this file and web page for others to see my page and download this .exe file with one click.
samyaditya [anti-spam] gmail.com December 7, 2011
please tell me how to use it, I have uploaded the file in public_html/Downloads & changed the base directory to 'public_html/Downloads'.. i have subdirectories in Downloads folder which contains the files to be downloaded.. now how to use the script..i m using directory listing script to browse folders on my website.. "www.ostwick.com" now plz tell me am i missing something out?? how to make it work, plz guys i m waiting for your reply..
December 7, 2011
Works great. thanks guys!!! :)
December 13, 2011
Great work... Thanks...
Emre December 18, 2011
Great but,



how can i do?
kasannes [anti-spam] qwest.net December 18, 2011
Hello, I can't seem to get this to work. I have altered and loaded the .PHP to a file called scripts. My download directory name is downloads. When I click on the link it opens up the script file and not the file for download. What have I done wrong here.
Sharma Ji December 19, 2011
Its a simple and easy script for download file.Thank you very much...
Jubri December 21, 2011
(Binxalot June 22, 2010)
There is one thing you need to add to this script if you are getting corrupted .Zips or .exe when downloading large files, look for the line:
Line 189:
print(fread($file, 1024*8));
print(@fread($file, 1024*8));
And, add two lines:
Line 181:

Now it works, no corrupt file

smdrafiqq [anti-spam] gmail.com December 26, 2011
Itz working fine for me. Thankz a lot for uy easy simple script! :)
amakussama [anti-spam] yahoo.com December 27, 2011
December 30, 2011
Very nice and useful code
stev [anti-spam] stevs.net January 6, 2012
Great script! Can I add more than one domain to ALLOWED_REFERRER? I'd like to enable several domains to access the download.
January 9, 2012
does it works for smart phones also
January 12, 2012
Super, very easy to install and works good. thanks for your work :)
eternalg1o1 [anti-spam] gmail.com January 17, 2012
i want to download all the images available in a website with a code which will make my task easire as downloading 1000 images at once by manually is a difficult task so is there any way to do it ??
if yes please do mail me , please i am in an urgent need of it
thank you
arulananth05 [anti-spam] gmail.com January 21, 2012

very help for me.
aman February 8, 2012
thanx a lot..
its working on local as well as online server...
Dipan February 9, 2012
Can we give resume support along with this script??????
eveklc [anti-spam] gmail.com February 13, 2012
Does this work for m4a files?
paigestormblade [anti-spam] live.co.uk February 15, 2012
ok this is a bit to confusing to read all that gone on Please specify file name for download. that what i get this does not open the directory files or search them to open a download does it?
KHANASIM26 [anti-spam] GMAIL.COM February 17, 2012
perchera [anti-spam] gmail.com February 22, 2012

Long hours looking for this.

I have to share plenty of files (some more than 100mb) and of course i don't want to link to the real path.

How can i make a download.php valid for multiple links, links that refer to diferent files?

Must all files be in the same directory?

Thank you!
Tomas February 24, 2012
S##t wont work.Keep saying "File does not exist. Make sure you specified correct file name." When I really know the file is there, browser downloads it nicely
russ [anti-spam] rldavies.org.uk February 28, 2012
Super php, been looking for ages, this does the job. One enhancement that really would be brilliant is the ability to have some sort of multiple file selection, to select a number of files and then hit the download, rather than have to do them individually.
greenwoodman1976 [anti-spam] yahoo.com March 3, 2012
Very handy and nice script. I was i could make a donation when my site is on.

greenwoodman1976 [anti-spam] yahoo.com March 3, 2012
paigestormblade [anti-spam] live.co.uk and other fellows,

"Please specify file name for download" is really confusing and looks like an error message though it is not.

The message indicates that your installation is successful and the script is expecting a file value or parameter to be passed on.

I shall request the programmer to replace this message with something like "Script installation is successful and ready for use."
greenwoodman1976 .yahoo.com March 3, 2012
paigestormblade [anti-spam] live.co.uk and other fellows,

"Please specify file name for download" is really confusing suddenly and looks like an error message though it is not.

The message indicates that your installation is successful and the form variable parameter ('f') is expecting a file name or value to pass on.

I shall request the programmer to replace this message with something like "Script installation is successful and ready for use."
Deepak Khandewal March 15, 2012
I want to download a file in php and show in the database.
Mo March 15, 2012
I've been looking for this script !!!!!
Thank You so much .... yay !!!
March 25, 2012
God Bless you for sharing!
Its working- finally!
My problem was the field where is specified the path to the file:
define('BASE_DIR','/Applications/MAMP/htdocs/php_test/'); (here it shows my path.
But after i solved this it's a butter-fly.
Thanks a million!
krittw [anti-spam] gmail.com March 28, 2012

Warning: opendir(/home/araboosc/domains/araboos.com/public_html/downloads/download.php?f=araboos-price.pdf/) [function.opendir]: failed to open dir: No such file or directory in /home/araboosc/domains/araboos.com/public_html/downloads/download.php on line 98

Warning: readdir(): supplied argument is not a valid Directory resource in /home/araboosc/domains/araboos.com/public_html/downloads/download.php on line 100
File does not exist. Make sure you specified correct file name.
amitzuting [anti-spam] hotmail.com March 30, 2012
Hi Zubrag,

I want to create a webpage where i can 1. upload a file from PC 2. I will mention Fist Name and Last Name 3. File Description And Last button "send My file". The file will be uploaded on the server in the folder named "Firstname-lastname" whose limit will 1GB. Once the file get uploaded to download that file a link will e received at firstname.lastname@domain.com. The user can use that link to download that files . The validity of file on the server will be 30days. I am using xampp for this. I have created database in Mysql and doing scripting in PHP. I have used file upload form from your website. Can you please assist for download link and email script.

Thanks in advance
Marcelo April 16, 2012
AWSOME! Works like a charm.
April 17, 2012
Is there a file limit on this?
Although I'm downloading small files, I have an .iso 4GB which can't download...
I'm getting

File does not exist. Make sure you specified correct file name.

TheGame April 19, 2012
i just get this msg when i eter my page: Please specify file name for download.

what do i do?
Nakul Chauhan April 27, 2012
Excellent!! Click click and implemented!!!
Gordon May 11, 2012
I am using this to download a large (932MB) zip file. The zip will not open when successfully downloaded. Checking the HASH I get two very different sums. Any ideas?
spacelanka.tk [anti-spam] gmail.com May 13, 2012
Oh my god. thanks a lot. just what im looking for and this realy works!. I have used it for my wallpaper site. thanks a lot
sethiya_jain [anti-spam] yahoo.com May 16, 2012
sir i have mp3 site when one user download any mp3 file other user not browse my site if i install this script my problem solve. please tell me or mail soon.
Recaro May 18, 2012
Nice script. Im using it for my site http://www.recarobyzoela.nl for downloading the specs of the car seats im selling.
vishnu May 26, 2012
to doen load from localhost use your foldes name at "/legs/images/"

$path = $_SERVER['DOCUMENT_ROOT']."/legs/images/";
TOM May 26, 2012
This will fix your problems the top Defines will find the directory form which the file downloads.php is being call from..

This fix will fix any directory problems you have with this script.

define('PATH_BASE', dirname(__FILE__) );
$parts = explode( DS, PATH_BASE );
define( 'PATH_ROOT', implode( DS, $parts ) );
define( 'PATH_SITE', PATH_ROOT );

// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )
define('BASE_DIR', PATH_SITE.DS.'media'.DS.'downloads'.DS);
TOM May 26, 2012
With this being the File pat used for others...
sorry for got to Remove mine from it ... but it works well
define('BASE_DIR', PATH_SITE.DS.'Location/of/file');
Bumiayu-Rosul June 9, 2012
Works Great..thanks
Joseph July 12, 2012
Am using the script for image downloads, it works fine on my local server but on the production server, once you download the images they don't open. I get an error like "Error interpreting JPEG image file (Not a JPEG file: starts with 0x3c 0x62)" how do i fix it?
CSharpDaniel July 21, 2012
I knew it's possible!
Thank you
Ikarus August 3, 2012
lo he estado buscando desde hace mucho tiempo y est aqu. Funciona perfectamente.

Muchas gracias!
Andrew September 4, 2012
Diab September 13, 2012
Thank you, it's working fine
ikagou [anti-spam] gmail.com September 14, 2012
I had the "file is corrupted or damage" error when I used this script initially. But after a few hours of searching online, I found the solution that might help anyone who has the same problem.

All you need to do is to add "ob_clean();" right before "$file = @fopen($file_path,"rb");" line and voila, everything works!

Hope that helps! ^^
September 17, 2012
the script works fine and was very sharp,even when i apply it to any of my web page
kanchancool.w [anti-spam] gmail.com October 8, 2012
hye ,,,,,
I need a php script for uploading and downloading mp3 file from my site. which is provid only songs...
so i want to save time.
help me plz..
Manjula October 19, 2012
it works..

Very Helpful my MCA Project, Thanks...
mamutije [anti-spam] mail.com October 20, 2012
I like your download script, but I can't download with a mobile divice. Why? Please help me :-)
kelljery [anti-spam] yahoo.fr October 24, 2012
The mime type defined with xlsx make firefox (and firefox only) to add "xls" to the filename and a warning message is displayed by excel.
the mime type below solve this issue:

'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation
Webtreemaster October 26, 2012
great script , i have it set up so the php file points to a .wmv file 189mb file size. everything works up to 28% and stops . after a few min the error reports download was interupted would you like to resume. so i click resume and it doesnt resume it starts all over again finishing off at 28%...?any ideas?
saaied October 28, 2012
tnx for this script...

this script work well but files in download folder is downloadable with download manager and no limite for anyone and any file ...

and if anyone get download folder pass, can download all files ...

kelljery [anti-spam] yahoo.fr November 2, 2012
this script does not work on site with https (ssl).
the downloaded file cannot be open (extention or fileformat error)
any solution ?
Sina November 10, 2012
Great Script. Thanks.

I just noticed that if you have duplicate file names under separate sub-folders, the last one (ascending order) will be downloaded. To fix this issue I added the following to the code:

// Get real file name.
// Remove any path info to avoid hacking by adding relative path, etc.
$fname = basename($_GET['f']);
$dname = str_replace("..","",dirname($_GET['f'])); // Added line, gets the relative folder name with check for hacking


find_file(BASE_DIR.$dname, $fname, $file_path); // Added section: .$dname

December 6, 2012
Yayyeee,...finally i found great script like this! lol....thank's for sharing this scripts for free :)
December 24, 2012
thanks.Great script
Drew December 28, 2012
Link seem to don't work with mobile..
http://goo.gl/hyx0j January 6, 2013
thanks for the script..
great script!
rajeshp22 [anti-spam] gmail.com January 14, 2013
Thanks a lot my dear friend. It works gr8!
ayxano [anti-spam] gmail.com January 18, 2013
hello! I can download flv files. but without extensions :( example: file is computer.flv it saves computer
free...links February 1, 2013
hello mate, I need your answers asap, can you reply thru email?

many thanks
February 4, 2013
all my compliments! Thank you so much!
Tom Clavel February 10, 2013
Works great! Couldn't be easier to understand and modify
jay_p72001 [anti-spam] yahoo.com February 12, 2013
great job
February 17, 2013
Can't believe my luck, been looking for weeks for a script like this, paid for a few and non have worked the way i needed it, then by accident i came across this page, Boy am i lucky, this script is just what i needed, spot on
solokool February 25, 2013
real php master
Ivan February 28, 2013
I really thank you for this. Your work is just amazing.
Daniel April 2, 2013
Is there a way to include the php like
<?php include('download.php') ?>
and short the url to something like
<a href="?f=test.zip"></a>
TABela April 24, 2013
Just replace:
// If hotlinking not allowed then make hackers think there are some server problems
&& (!isset($_SERVER['HTTP_REFERER']) || strpos(strtoupper($_SERVER['HTTP_REFERER']),strtoupper(ALLOWED_REFERRER)) === false)
) {
header("Location: http://your site url here :xD");
samath June 2, 2013
that really cool
shailesh2work [anti-spam] gmail.com June 3, 2013
Use this site http://www.freefblike.com to promote every pages of your website on Facebook Google, Twitter and LinkedIn.
maaan!!! June 13, 2013
Thanks mate, you literally saved my ass!!
I have been searching for sth like for 4 hours and yours is what I was looking for!
Ea Arts June 30, 2013
Man! You're the best!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
ilia July 19, 2013
tnx man
July 28, 2013
Nice work, it works like a charm, saved me a lot of code writing and its the most efficient compare to the ones I've came accross so far though for msword document ".doc" seemed not to work, it works proper with ".docx"
Stan August 19, 2013
I have hundreds of files with the same name, but all in different folders. Unfortunately the script ignores the folder info, and grabs the first matching file it can find. I've tried Sina's solution above, but it didn't do the trick, with the modifications the script doesn't download anything.
How can I force the script to download the file from the proper directory?
I use this call: mydomain.com/script directory/dl.php?f=subdirectory1/subdirectory2/filename.
PS August 24, 2013
I found this solution is dangerous. If somebody knows your website structure and play with f="../protected_directory/a_file_name_with_passwords.php he can get a file from protected directory, example a file with passwords to connect to db. You need to disinfect variable f before you send it to the script.
ouch November 9, 2013
I downloaded this a few months ago and only just looked at it and came back to say the same thing as the person above.

Stan November 17, 2013
The script works perfect! And no, ITS NOT DANGEROUS!

just put the download.php in a single folder with no other files, and nobody can get files from a protected directory.
Maria November 20, 2013
Can this be downloaded to an android phone? I'm trying to download it to my Galaxy 4, but it wont open.
davedc.collins [anti-spam] gmail.com November 28, 2013
It doesn't work for android downloads or windows phone. Ideally it needs updating to overcome this if anyone can post a solution
jhunaboc [anti-spam] gmail.com December 6, 2013
sir i ask how i could fix this problem because when i run the program it show this text "Please specify file name for download." .. can you help me? tnx :)
December 15, 2013
I agree, this script is not dangerous. I've used it on lots of sites now and it works just great. I find the log file particularly useful to check if someone's downloaded a particularly big or sensitive file after I've sent them the link, so I can delete the file. I'm using it on my latest site here ([url=http://www.tsg.ge/]www.tsg.ge[/url]) but I'd like to see an advance version with email sign up (and email address verification). Thanks!
Esteban December 21, 2013
Please someone tell me if this serves to external servers like dropbox

4 [anti-spam] help.com January 29, 2014
Hi all,

In the process of building a site to learn.
I am new to php and mysql and hope that some of you better educated in this area than I, can/will help me. (Please)
I have created a download.php and entered the script with 2 edits.

1. I had to remove Set maximum script execution time as host denies it.
--> Removed "set_time_limit(0);" <-- (No Choice - Host will not allow as security risk)
2. I changed file path to my downloads folder - define('BASE_DIR','/public_html/downloads/');

All I see when I open the download.php - "Please specify file name for download."

I have 1 .mp3 file (compressed) as .zip in the downloads folder for testing and need to know how I can show it and others when I want to download them...?????????

Free hosting with ("000webhost.com") to test and learn how to use this as they allow all these scripts.

Any help appreciated. Thanks in advance.
Iman January 30, 2014
I extract it and run it, but it does not work :(
Nate February 2, 2014
It works fine, I literally just added it to my site and tested a download and it works.
danmurphy2 [anti-spam] gmail.com February 19, 2014
Avoids direct files download, hides real file paths??
Can't you find real path by looking at page source code??
February 24, 2014
Please help. I try to use this script. But I can't get my file. the file I downloaded was open to a webpage format instead of a download file.
Amit Yadav March 28, 2014
<a href="download/new.pdf" target="new">Download</a>
saim April 2, 2014
PLEASE HELP. It is showing the code of file like

PDF-1.5 % 1 0 obj <>>> endobj 2 0 obj <> endobj 3 0 obj <>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 612 792] /Contents 4 0 R/Group<>/Tabs/S/StructParents 0>> endobj 4 0 obj <> stream xZnH}7h̾Hay] l9>q":ռ5Ŗ,GvU׽NuK ^z~Z^g/J!}."E{NgIO(}/ggW6σB q9ge9g\[ސ4s'2|ZRZPRJ\V:B@W SoqC)G(&"2'ۈy4S!`O7rU0*8q1k

Add Comment

!!! Comments posted here will not be answered. If you want to ask a question please post it on the forum.

E-mail or Name: Not required. Email will be protected from spammers

Comment: Please do not post unrelated comments

Anti-spam: Please enter (c6b5aa80) into the box