CodeIgniter Forums
File uploading save file as - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: File uploading save file as (/thread-11201.html)



File uploading save file as - El Forum - 08-29-2008

[eluser]neosable[/eluser]
How do I set the name of the file when using the file upload class?
thanks


File uploading save file as - El Forum - 08-29-2008

[eluser]Colin Williams[/eluser]
Are you familiar with how PHP handles file uploads? It saves the posted files to a temporary folder and then it is up to the given script to move those files over to a permanent location. CI's file uploading simple mitigates that process through a clear API.

So, just rename the file(s) after "uploading" them. Use the [url="http://us2.php.net/rename"]rename()[/url] function, believe it or not! Tongue


File uploading save file as - El Forum - 08-30-2008

[eluser]neosable[/eluser]
so basically instead of saving the file to windows/temp (in case of windows user) CI saves the file to the folder I set in the configand then I have to move it .


File uploading save file as - El Forum - 08-30-2008

[eluser]Colin Williams[/eluser]
Oy.. no, CI moves it to $config['upload_path']

By the way, someone just extended CI's uploader class to allow for custom renaming, which he claims is set up to automatically handle filename clashes.. check it at http://ellislab.com/forums/viewthread/89603/