download script

From: Date: Wed, 11 Aug 2004 17:06:21 +0000
Subject: download script
Groups: php.general 
Request: Send a blank email to php-general+get-193327@lists.php.net to get a copy of this message
I was going to post another follow-up question in a pending thread here but it seems to have been deleted. Anyway, I am trying to write a download script that will downloaded files from my site. All these files need to be protected so just anybody cant come to the site and download them. I have already created a login environment for this site and just need to make my file downloads work. Currently they are in a directory protected by .htaccess. I was told on the previous thread that I needed to place the files that are protected by .htaccess ouside of the webroot in order for PHP to have rights to them. My web root is /home/lgxdlr/mainwebsite_html/ I put the secure directory called test in /home/lgxdlr/ I am trying to dowload a file using readfile(), but PHP still cant seem to get to the file. Here is my code: <?php $file = "/home/lgxdlr/test/".$_GET['file'].""; if (file_exists(basename($file))) { header("Content-Description: File Transfer"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($file)); @readfile($file); } else { echo "$file<br>"; echo basename($file); echo "<br>No File Found"; } ?> If anyone can give me a hand with this please post. Thanks, Aaron

« previous php.general (#193327) next »