Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
05-28-2004, 05:22 PM #1
- Join Date
- May 2004
- Thanked 0 Times in 0 Posts
download AND delete a file from the server
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, 02:08 AM #2
- Join Date
- May 2002
- Perth Australia
- Thanked 98 Times in 96 Posts
you can create a page that handles the download and unlinks the file easily enough ...
BUT , what if the client does not complete the download , or if on occaision you have a corrupt download ?PHP Code:
/*you may need to set the right headers for the file type*/
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)
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)