Jragon Posted December 13, 2010 Share Posted December 13, 2010 Hello, I was wondering how you can find out the extension of the image (so .gif, or .jpg). Because i need to make an image uploader thingy, and i want to change the name of the picture to some random string, but keep the extension the same. My friend said i could do it in regex but i have no idea.. Thanks Jragon. Link to comment https://forums.phpfreaks.com/topic/221542-how-can-i-find-out-the-extension-of-the-picture/ Share on other sites More sharing options...
AbraCadaver Posted December 13, 2010 Share Posted December 13, 2010 $pathinfo = pathinfo('/path/to/your/image.gif'); $extension = $pathinfo['extension']; Link to comment https://forums.phpfreaks.com/topic/221542-how-can-i-find-out-the-extension-of-the-picture/#findComment-1146801 Share on other sites More sharing options...
Jragon Posted December 13, 2010 Author Share Posted December 13, 2010 So if i did, $pathinfo = pathinfo($_FILE['file']['name']); that would work? Link to comment https://forums.phpfreaks.com/topic/221542-how-can-i-find-out-the-extension-of-the-picture/#findComment-1146807 Share on other sites More sharing options...
AbraCadaver Posted December 13, 2010 Share Posted December 13, 2010 Yes, or shorten it: $extention = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); Link to comment https://forums.phpfreaks.com/topic/221542-how-can-i-find-out-the-extension-of-the-picture/#findComment-1146816 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.