0

I used this answer to allow a user to upload files to my webserver. I now wish automatically delete all files after 10 minutes of being uploaded. How can I do this in the simplest way possible?

PS I'm very new to web development and so details will be appreciated :)

Community
  • 1
  • 1
nam
  • 3
  • 3

1 Answers1

0

You could make every image accessible via a php file, i.e image.php?n=whatever.jpg that way you can check the create date of the file, if it's been 10 minutes delete the file and give an error, if not, give them access.

On actually deleting the file, use unlink()

However, this would require the user to actually try and access the file again, another way would to set up a cron job to automatically delete files that have existed longer than 10 minutes - but this was tagged as PHP so I thought of other solutions.

Daniel
  • 1,229
  • 14
  • 24