Page 1 of 1

renaming image files

Posted: Thu Dec 11, 2008 5:51 am
by nfrandsen
hi,
im trying to let users upload a profile picture of themselves on a simple website I am creating. I want the picture to be renamed to their userid number and placed in a directory containing all other profile pics, therefore I use the zend form rename filter, BUT, i can't figure out how to make it keep the original file extension:

->addFilter('Rename', '/Applications/xampp/xamppfiles/htdocs/places/web_root/img/profile/' . (int)Zend_Auth::getInstance()->getIdentity()->id);

this works fine, except it creates the file without a filename extension. Sure i could add a . '.jpg' to the end of that and it would create a jpg file but then it would also rename .gif and .png. how can i flexibly rename the filename but keep the file extension?
Thanks a lot for the help!

Re: renaming image files

Posted: Thu Dec 11, 2008 10:01 am
by pickle
I'm not sure how to do this with just Zend code. Usually, I'd run it through getimagesize() to determine what type of file it is, then tack on the appropriate extension after renaming.