Hi,
I'm trying to setup the security of download files, instead of having the a folder in the website, I want the file on the server root (d:/webdownload/file.zip).
Is there any way to do this (I'm using Win2k & IIS)
Thanks
Tzaff
| SitePoint Sponsor |
Hi,
I'm trying to setup the security of download files, instead of having the a folder in the website, I want the file on the server root (d:/webdownload/file.zip).
Is there any way to do this (I'm using Win2k & IIS)
Thanks
Tzaff





Your best bet is to use php to force a download of the files. Take this example.
Code:<? $fileroot = 'D:\\webdownload\\\'; if(!file_exists($fileroot.$file)) { print "Yeah right jerk"; exit; } header("204 No Content"); header("Content-Type: ".filetype($fileroot.$file)); header("Content-Disposition: attachment; filename=\"".$file."\""); readfile($fileroot.$file); ?>
I named this file dl.php and stuck it in my web root. Then to allow downloading of a file not in the web root, I simply link to this file in the form of.
dl.php?file=filetodownload.zip
It will make sure the file exists and only in that folder, then it will force a download of the file with the proper name.
Please don't PM me with questions.
Use the forums, that is what they are here for.
Thanks, but I've got a stupid question: The file exists, I changed the 'print' to 'download will start automatically', this appears, but no download is starting... even if should... I copied your code but nada :-(
Any suggestion(s) ?
Tzaff
Thanks, but I've got a stupid question: The file exists, I changed the 'print' to 'download will start automatically', this appears, but no download is starting... even if should... I copied your code but nada :-(
Any suggestion(s) ?
Tzaff





If the words(Yeah right jerk) are getting printed, then the file does not exist and the prog exits. If the file exists the words(Yeah right jerk) should not be seen on the screen. I am sayingif the file DOES NOT EXIST, don't initiate the download and exit after printing an error message.
Please don't PM me with questions.
Use the forums, that is what they are here for.
Thanks, I'll try this again and check the spelling again and again. I'll keep you in touch
Tzaff
Perfect, it's working fine, the admin changed the path without telling me
.
Now an other question, the last one..., when the download starts, the download screen appears with the following infos:
You are downloading the file:
pagename.php?id = 1 from www.mysite.lu
But this is not very good looking. Is there a way to but the filename instead of this long info, something like:
You are downloading the file:
nameofthefile.zip from www.mysite.lu
Thanks
Tzaff
Bookmarks