CodeIgniter Forums
Change file extenstion with upload class - 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: Change file extenstion with upload class (/showthread.php?tid=26387)



Change file extenstion with upload class - El Forum - 01-12-2010

[eluser]dorwin[/eluser]
Hello,

I see I can rename a just uploaded file with this class :

Quote:file_name Desired file name

If set CodeIgniter will rename the uploaded file to this name.

Note:The filename should not include a file extension.
But is it possible to change file extension, like .JPG in .jpg without use ftp class ?
Because sometimes servers bug if mypic.JPG is called by <img src='mypic.jpg' />

Thanks !


Change file extenstion with upload class - El Forum - 01-12-2010

[eluser]danmontgomery[/eluser]
You can use rename() to rename the file once it's been uploaded: http://php.net/manual/en/function.rename.php


Change file extenstion with upload class - El Forum - 01-12-2010

[eluser]dorwin[/eluser]
Too willing to use CodiIgniter, we come to forget base php Wink
Code:
rename($image['full_path'], strtolower($image['full_path']));
Thanks Smile