I'm working on a PHP web application which will accept Markdown files as a file input.
How should I make sure that Markdown and only Markdown files are being uploaded?
I think I should check more than the extension... maybe the mime type?
If so, what is that mime type?
extension and mime type are same.
check UTF-8, you can block any binary files (image files, etc)
if ($markdown !== iconv("UTF-8", "UTF-8//IGNORE", $markdown)) {
if an user uploads a HTML or JavaScript file, it is not what you want, but it match the Markdown syntax. so PHP can't identify it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With