我想看看如何通过 PHP 检查上传的文件是否带有病毒.存在哪些选项,每种选项的优缺点等.
I am looking to see how I can go about checking if an uploaded file has a virus or not via PHP. What options exist, pros and cons of each, etc.
ClamAV 是服务器上常用的免费杀毒软件应用程序.
ClamAV is a free anti virus commonly used on server applications.
php-clamav 是一个将 ClamAV 绑定到 PHP 的扩展.您可以查看他们的文档.
php-clamav is an extension for binding ClamAV to PHP. You can check their documentation.
我找到了一个 关于如何使用 clamav 作为 Zend 框架验证器的教程,其中已经包含有关如何验证上传文件的说明.本教程还应该帮助您在其他框架或架构上使用它.
I've found a tutorial on how to use clamav as a Zend Framework Validator which already includes instructions on how to verify upload files. The tutorial should also help you on using it on another frameworks or architectures.
您还可以使用 clamscan
通过命令行界面调用 clamav.这需要安装 clamav 但不需要安装 PHP 扩展.在 PHP 端,您可以 shell_exec('clamscan myuploadedfile.zip');
然后解析输出.以 OK
结尾的行是安全文件,以 FOUND
结尾的行是恶意文件.
You can also call clamav by its command line interface with clamscan
. This requires clamav to be installed but not the PHP extension. In the PHP side, you can shell_exec('clamscan myuploadedfile.zip');
then parse the output. Lines ending with OK
are safe files, lines ending with FOUND
are malicious files.
这篇关于我有哪些选项可以检查 PHP 上传中的病毒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!