本文介绍了有没有办法验证PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我希望为我的客户提供一种将pdf上传到他们网站上的方法。是 有任何脚本可用于区分真正的pdf 文件和带有.pdf的恶意文件。扩展名? 解决方案 每次上传时,做一些服务器端MIME类型总是一个好主意 猜测。在PHP中,你有一个不推荐使用的内置函数: http://es2.php.net/manual/en/functio...ntent-type.php ....和PECL扩展(见上页链接) 如果它是Unix主机,你可以使用优秀的文件。程序: 您可以检查文件的前5个字符,如果是真实的pdf,它们包含%PDF- 。接下来的4个包含版本(即1.2) Bill H I want to give my customers a way to upload pdf''s onto their sites. Isthere any script that can be used to distinguish between a true pdffile and a malicious file with a ".pdf" extension? 解决方案On every upload it''s always a good idea to do some server-side MIME typeguessing. In PHP you have a deprecated builtin function: http://es2.php.net/manual/en/functio...ntent-type.php.... and a PECL extension (see link in the above page)If it''s a Unix host, you can probably use the excellent "file" program:You can check the first 5 characters of the file, they contain %PDF-if it is a real pdf. The next 4 contain the version (ie 1.2 )Bill H 这篇关于有没有办法验证PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!