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/dlr/mainwebsite_html/  I put the secure
directory called test in /home/dlr/

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/dlr/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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to