問題描述
我想看看如何通過 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模板網!