View Full Version : download AND delete a file from the server
05-28-2004, 06:22 PM
i'm providing downloadable executables for several particularly ignorant clients who i cannot trust to be able to delete the file from their folder once downloaded (this is necessary) - i'd be very appreciative of some help with a script that would first download a file and then delete the same file from the remote directory...
it's a very inexpensive website, don't want to mess with a database ... just a simple download script that might include an unlink() function...?
thanks so much,
05-29-2004, 03:08 AM
you can create a page that handles the download and unlinks the file easily enough ...
/*you may need to set the right headers for the file type*/
BUT , what if the client does not complete the download , or if on occaision you have a corrupt download ?
you can count bytes using fopen,fread,fputs etc but that does still not proove that the downloaded file actualy made it in one piece.
I had to do something similar once & the end result was to mark a file as 'downloaded' in a database (or flatfile/whatever) then run a timed cron job to delete all such files if the transaction was $x hours old, the logic being that if they had not actually downloaded the file is $x hours then it was their problem, far from perfect.
We could not find a way to validate that the file had actually downloaded and was in good shape, other than relying on the user to confirm such. (short of having control of the users machine and running a script to check such)
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.