开发者

PHP Upload PDF mime type is application/unknown

I am having this开发者_开发问答 problem uploading PDFs to site.

I try it on one a computer, OS X, the mime/type is application/unknown. But when I try to upload the PDF from another mac, after sending it over by email, the mime/type is application/pdf.

What could be causing this problem?

Upload is done through PHP so I get the mime/type through $_FILE['name']['type']


Pro forma answer since your question is too vague without any code: The mime type for file uploads is indeterminate. Browsers simply attach files in a multipart <form> and add a mime type on a best guess basis. What PHP sees in $_FILES["upload"]["type"] is not necessarily correct and could even be intentionally false.

It's best to ignore this field and instead use mime_content_type($_FILES["upload"]["tmp_name"]) or similar methods to determine the correct content type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜