CodeIgniter Forums
Storing temporary images - is there a best practice approach? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Storing temporary images - is there a best practice approach? (/showthread.php?tid=22226)



Storing temporary images - is there a best practice approach? - El Forum - 09-01-2009

[eluser]rvillalon[/eluser]
I have an "add product" section on my site in which I use flash+jquery to upload images relating to products. It saves images to my website before creating the product. So, sometimes, if I upload images and don't go through creating the product, it just sits in my server.

I'm trying to improve my system so I was wondering what would be a good way to temporary save the images?

In a nutshell, once a product is added, temporary images get linked to their respective product.

I figure I have two options:

Option 1 - Sepeaated
- Have a temporary upload directory (/temp_images)
- Have a saved upload directory (/saved_images) - once the user saves the product, the images get moved here
- Have an images_temp table to track the temporary images (file name, who it belongs to, upload datetime)
- Have an images_saved table to storehouse the saved images

Option 2 - Not separated
- Store all images (temporary or not) in one folder
- Have one image table to track the images

Everyday, I would run a script to clean up any temporary images laying around.

Which option is better? And why? If you have database design tips too, that would help!

Any comments are greatly appreciated!


Storing temporary images - is there a best practice approach? - El Forum - 09-03-2009

[eluser]bretticus[/eluser]
I think the easiest option is Option 3
- Have a temporary upload directory (/temp_images)
- Have a saved upload directory (/saved_images) - once the user saves the product, the images get moved here
- Have a cron job and use a variation of the find command to delete images older than x number of days in the temp folder.