PHP:如何在上传之前扫描任何文件中的病毒

时间:2014-08-23 22:00:30

标签: php virus

在上传之前有没有办法检查文件,它有病毒吗?

我的代码上传是: -

function uploadfile()
{
    $allowedExtensions = array("jpg","jpeg","gif","png","doc","pdf","ppt","zip","rar","xls","pptx","docx","xlsx");
    $split=explode(".",$_FILES["filework"]["name"]);    
    $type=strtolower($split[sizeof($split)-1]); 
    $rname=time().".".$type;
    if (in_array(end($split),$allowedExtensions)) { 

    $destination = "uploads/".$rname;
    $temp_file = $_FILES['filework']['tmp_name'];
    move_uploaded_file($temp_file,$destination);
    return $rname;
    }
    else {return false;}

}

1 个答案:

答案 0 :(得分:6)

不,必须先将文件上传到您的服务器,然后再进行扫描。如果您还没有该文件,您如何扫描它?