CodeIgniter Forums
Temporary files, how is it done? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Temporary files, how is it done? (/showthread.php?tid=24609)



Temporary files, how is it done? - El Forum - 11-14-2009

[eluser]überfuzz[/eluser]
I'm building a upload system that allows users to upload pictures that are going to be displayed on the website. Now I'm wondering if there is any good way of handling these picture files? Is there any CI way of handling temp-files or should I go with good old php. If so, when and how should I trigger a flush of the temp-directory?


Temporary files, how is it done? - El Forum - 11-14-2009

[eluser]überfuzz[/eluser]
I guess I'll go with this, or similar...

1. [Preview] --> in a view file.
2. Upload a pic to ../temp/
3. Display ../temp/picture.jpg in a view file.
4. [Submit] --> move preview to ../images/
5. unlink( ../temp/picture.jpg);


Temporary files, how is it done? - El Forum - 11-14-2009

[eluser]Vi.[/eluser]
There is an Image and Upload library in CI if you didn't check that.
Image Manipulation Class

Upload image and resize uploaded image to preview size without saving. Use header() to send image data throughly browser. CI image resizing is easier then native php code.

I will copy-paste my code here When I found it.


Temporary files, how is it done? - El Forum - 11-14-2009

[eluser]Jondolar[/eluser]
I recommend using the move_uploaded_file() php function and let PHP handle everything else.


Temporary files, how is it done? - El Forum - 11-15-2009

[eluser]überfuzz[/eluser]
@Vi - The image class is just what I need. Seems to give me clean code. I'll use the work flow I described. Thank you.