views:

191

answers:

5
+2  Q: 

Images management

Im building a site were users can upload images and then "use" them. What I would like some thoughts and ideas about is how to manage temporary uploads.

For example, a user uploads an image but decides not to do anything with it but just leaves the site. I have then either uploaded the file to the server or loaded it to the server memory. But how do I know when the image can be removed? First I thought of just having a temporary upload folder which is emptied periodically but it feels like there must be something better to do?

Btw im using cakephp, mysql, although images are stored on the server and only the location is stored in the db.

Cheers Bjorn

A: 

You could try to define a "session" in some way and give the user some information about it. For example, in SO, there is a popup when you started an answer but try to leave the site (and your answer would be lost). You could do the same and delete the uploaded image if the user proceeds. Of course, you can still use a timeout or some other rules (maximum image folder size etc.).

schnaader
+3  A: 

Save the information about file to MySQL, and save the last time the image was viewed - can be done via some script that would be altered everytime the image is being used.. and check the database for images not used for 30 days, delete them..

Skuta
A: 

check the last accessed/modified time of file to see if it used.

dusoft
A: 

I'm not sure what does "temporary upload" mean in your app. The file is either uploaded or not, and under the ownership of a user. If a user doesn't want to do anything at the moment, you have no other choice but to leave the file where it is.

What you can do is put a warning somewhere on your image management page about unused images, but removing them yourself seems like a bad practice (at least from the user perspective).

dr Hannibal Lecter
A: 

As a user,When I upload the image to a server(assuming I want to use it later) and leave the site, I don't expect it to be deleted if I am a registered user.

I would prefer it to be there in my acct until I come back.I would suggest thinking in those lines and implementing a solution to save the users' images if possible.

schar