我有一个安全的文件上传功能,它是我网站的一部分我正在使用防病毒软件来帮助我检查用户试图上传的文件。
这是我的上传进程.php文件
$target_tmp = "D:avscanu\";
$file = basename( $_FILES['uploaded_file']['name']) ;
if($file != "")
$_SESSION['file'] = $file;
$target = 'C:xampphtdocsssdUploads\';
$file_path = $target_tmp.$file;
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path))
{
$safe_path = escapeshellarg($file_path);
$command = 'scancl'. $safe_path. ' --stdout';
$out = '';
$int = -1;
$output = exec($command, $out, $int);
echo "The output is" .$output;
echo $int;
exit(0);
//Checking for Virus.
if ($int == 0) {
$target = $target.$file;
//echo $target; exit(0);
copy($file_path, $target);
$uploaded = "The file ". $_SESSION['file']. "has been uploaded";
$clean = 'File is Clean.';
$_SESSION['status'] = $clean;
$_SESSION['upload'] = $uploaded;
header("location: ../upload.php");
exit(0);
}
// File is a virus.
else {
$mal = 'Contains Malware';
$deny_up = "Unable to Upload Your File!";
$_SESSION['status'] = $mal;
$_SESSION['upload'] = $deny_up;
header("location: ../upload.php");
exit(0);
}
}
else
{
echo "SORRY, There was a Problem Uploading Your File."; exit(0);
$err_upload = "SORRY, There was a Problem Uploading Your File.";
$_SESSION['err'] = err_upload;
header("location: ../upload.php");
exit(0);
}
它为我打印所有文件(恶意和非恶意)的$int值1。这是我第二次尝试使用不同的AV,现在我使用Avira,以前我使用翻盖
有人能给我一些提示吗,告诉我发生了什么事
PS系统安装在XAMPP上,如果这有任何不同的话
您能更具体地说明什么在这里不起作用吗?理论上,你所做的似乎很好,至少对ClamAV来说是这样,因为它有以下返回代码(来自man clalcon):
RETURN CODES
0 : No virus found.
1 : Virus(es) found.
2 : Some error(s) occured.
也许它想记录exec调用的输出,如果你没有得到你期望的退出代码,原因应该在输出中(比如缺少命令行标志)。