type in uploaded file
I have form for file uploading in my website that i check mime-type of uploaded file to allow or refuse uploading it. It worked well until I've upgraded my firefox to 3.6.11 (in ubuntu). But now uploading Doc files is not possible. I checked the mime-type of file but it was 'application/x-php' instead of 'application/vnd.ms-word' or other msword mime-types.
I use
echo $_FILES[$fileName]['type'];
to see the mime-type. I upload the same file from firefox 8 and firefox 3.6 and the output of above code was:
FireFox 8: application/vnd.ms-word
FireFox 3.6: application/x-php
Is it a bug of firefox or I have to change my codes?
I use PHP.
$_FILES[...]['type']
is just arbitrary, user supplied, best-guess, unreliable (as you see) information supplied by the client which may or may not have anything to do with the actual file. Never use it.
Try to detect the MIME type yourself on the server. For example techniques, see How to get the content-type of a file in PHP?.
链接地址: http://www.djcxy.com/p/45526.html上一篇: 服务器上的PHP文件上传改变了MIME
下一篇: 键入上传的文件