Downloading Files
Hello!
Heres what I want, I have files on my server, for example 1.exe, 2.zip.
Through a PHP script I want to allow the user to download then but under a new name, for example 1.exe will be called Setup.exe and 2.zip would be Music.zip.
I want this to go through a PHP script to incrmement a download counter, to hide the original URL and to enforce permissions.
Thanks :D
# 1 Re: Downloading Files
well a redirect header would have the page start the download. Dont know if you can change the name. What if you just change the name on upload?
dclamp at 2007-12-4 16:47:15 >

# 2 Re: Downloading Files
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="setup.exe"');
readfile('example1.exe');
# 4 Re: Downloading Files
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="setup.exe"');
readfile('example1.exe');
As long as you are careful to send no headers you can use this to record downloads with a text file or database connection. Put the counter increment code before that code and you are all set.