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. Quote 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']; Quote 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? Quote 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); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.