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?? Quote Link to comment 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"] Quote Link to comment Share on other sites More sharing options...
gatzkerob Posted May 26, 2011 Author Share Posted May 26, 2011 Thank You! Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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.