Forum Moderators: coopster & phranque

Message Too Old, No Replies

Auto Delete

Auto Dlelte File after download.

         

Stalka

6:50 pm on May 20, 2003 (gmt 0)

10+ Year Member



hey,

I was wondering if any of you could help me out. Ive had a browse through the forums to see if this topic was here....but if i have missed it please excuse me.

I am looking for a script where after a users download has finished, the file they just downloaded is deleted from the server.

Or

A Cron job that would purge a certain directory after the file is (x)minutes old.

Is any of this possible or am i in dream land?

Thankyou in advance & i await any responce anybody has to offer,

§talka

jatar_k

6:57 pm on May 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Stalka,

I dont see why it wouldnt be possible.

The cron would be simple, you could just look at the date/time created on the file and nuke if older than x.

You may be able to do it when someone downloads as well, you would need to find out if the download has finished and then nuke.

What language are you looking for?

BCMG_Scott

6:59 pm on May 20, 2003 (gmt 0)

10+ Year Member



In Perl or PHP:

unlink($filename);

Scott Geiger

daisho

7:04 pm on May 20, 2003 (gmt 0)

10+ Year Member



you may want to wrap this in something like "download.php". Have that feed out a file based on parameters. Once finished you can then remove the file or ensure that if called with the same parameters the file will not be sent. Not sure what your application is or how the files are generated.

Other than that jatar_k's right cron would be easy to setup.

Stalka

7:05 pm on May 20, 2003 (gmt 0)

10+ Year Member



hi..

Thankyou for the fast reply's.

I would like the language to be PHP if possible although i would consider anything else that would do the job.

--Jatkar_k, would the date/time creation of the file be possible as the file is currently being copied into a public area of my site from an "off tree" directory to allow download. Would the date/time be that of the original file or that of the time/date it was copied?

--BCMG_Scott
unlink($filename); ....i am not familiar with this command :-( ..can you offer any more help please?

§talka

jatar_k

7:14 pm on May 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



probably date/time it was copied but not sure you would have to test.

in php
unlink() [php.net]

BCMG_Scott

7:51 pm on May 20, 2003 (gmt 0)

10+ Year Member



unlink is an old C function that has made it into both Perl and PHP. Basically it will delete the filename passed to it. So if I do:

unlink('/tmp/upload_123.gif');

Then the file /tmp/upload_123.gif will be deleted. You can find more documentation on it at php.net under their online document (or search for unlink).

Scott