mostafatalebi Posted March 17, 2013 Share Posted March 17, 2013 Hello everybody I have a file-upload form. I dont know how to match file-type/mime-type. Using FILE_EXTENSION, I heard it is absolutely vulnerable to hacking. I'm confused how to handle it...! Please help me. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/275767-best-way-to-get-file-mime-typeextension/ Share on other sites More sharing options...
doddsey_65 Posted March 17, 2013 Share Posted March 17, 2013 I usually use pathinfo() to get the extension of files. $ext = pathinfo($_FILES['file'], PATHINFO_EXTENSION); Quote Link to comment https://forums.phpfreaks.com/topic/275767-best-way-to-get-file-mime-typeextension/#findComment-1419131 Share on other sites More sharing options...
mostafatalebi Posted March 17, 2013 Author Share Posted March 17, 2013 what's the problem with $_FILES[name][type] ? Quote Link to comment https://forums.phpfreaks.com/topic/275767-best-way-to-get-file-mime-typeextension/#findComment-1419158 Share on other sites More sharing options...
jcbones Posted March 18, 2013 Share Posted March 18, 2013 I use getimagesize. Quote Link to comment https://forums.phpfreaks.com/topic/275767-best-way-to-get-file-mime-typeextension/#findComment-1419224 Share on other sites More sharing options...
mostafatalebi Posted March 18, 2013 Author Share Posted March 18, 2013 getimagesize is only for images. I need some documents to be checked, such as word, excel, pdf and so on. Quote Link to comment https://forums.phpfreaks.com/topic/275767-best-way-to-get-file-mime-typeextension/#findComment-1419275 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.