Php get pdf mime type




















Returns the MIME content type for a file as determined by using information from the magic. Submit a Pull Request Report a Bug. Parameters filename Path to the tested file. Lukas V is IMO missing some point. The MIME type of a file may not be corresponding to the file suffix. Imagine someone would obfuscate some PHP code in a. The server can issue an error, i. The original expression would not work if the filename is a relative path.

It should also work on Windows hosts with msysgit installed. I see a lot of comments suggesting doing file extension sniffing i. I want to point out that there is a much more accurate way. Some systems won't add the charset bit, but strip it off just in case. The '-bi' bit is important. The only drawback is that your scripts will not work on Windows, but is this such a problem?

Just about all web hosts use a UNIX. It is a far better way than just examining the file extension. The updated version below corrects this problem. But thank you! Forgetting the breaks was the problem! Davit Davit 1, 5 5 gold badges 20 20 silver badges 47 47 bronze badges. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.

Linked Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.



0コメント

  • 1000 / 1000