gatzkerob Posted May 26, 2011 Share Posted May 26, 2011 Is it not possible to get the mime type for a file uploaded using php? Am I going to be forced to use Pear? Php can read the mime type from an image, so why not from any file?? Link to comment https://forums.phpfreaks.com/topic/237556-mime-type-using-just-php/ Share on other sites More sharing options...
fugix Posted May 26, 2011 Share Posted May 26, 2011 yeah wouldnt you just use $_FILES["file"]["type"] Link to comment https://forums.phpfreaks.com/topic/237556-mime-type-using-just-php/#findComment-1220715 Share on other sites More sharing options...
gatzkerob Posted May 26, 2011 Author Share Posted May 26, 2011 Thank You! Link to comment https://forums.phpfreaks.com/topic/237556-mime-type-using-just-php/#findComment-1220796 Share on other sites More sharing options...
gatzkerob Posted May 26, 2011 Author Share Posted May 26, 2011 yeah wouldnt you just use $_FILES["file"]["type"] Actually, I don't think this is what I was looking for. A user could change the file extension to whatever they want. What I need is a way of confirming that the file is in fact what the file extension says it is. Link to comment https://forums.phpfreaks.com/topic/237556-mime-type-using-just-php/#findComment-1220806 Share on other sites More sharing options...
xyph Posted May 26, 2011 Share Posted May 26, 2011 Mime type is based on the extension, not necessarily the contents. You will have to read the raw bits and parse manually. There's not much harm though, seeing as malicious code uploaded as a jpg file should never actually get executed as PHP, because the extension is not .php Link to comment https://forums.phpfreaks.com/topic/237556-mime-type-using-just-php/#findComment-1220813 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.