Use PHP's file functions to read the file and output it to the browser, sending the attachment header so it opens the save as dialog. After you finish outputing the file unlink() the file.

Another way to do this is to store the files outside your www root, then authorize the user to access the file by giving them a URL with a unique id on the end like auth=ADFS_Ddadfass that is randomly generated. When the script is visited it looks in the database, checks to see if the auth variable is a valid download key if it is it reads the file and outputs it, if it isn't then it refuses the download. This method allows you to set a timeout for example they can download the file for 4 hours (store the unix timestamp in the database and look for records that are less than 4 hours long and match the download key). If you only wanted them to download once with this method just delete the key from the database once the download occurs, this will be less resource intensive because you aren't copying and deleting files on every download.

Jason

Jean-Christian IMbeault wrote:

Jim Lucas wrote:



actually, you should be able to do this without ever leaving the page that
were clicking from.



I wasn't clear enough in my original post. You are right that the user never leaves the page he is on. That's ok.

But what I would like to do is have the page reload itself so that it
can remove the file that has just been downloaded from it's list.

Is that possible?

Thanks,

Jean-Christian Imbeault






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



Reply via email to