Jump to content

Antivirus scan during uploading a file


khhalid

Recommended Posts

Hi Guys,

I am trying to do an anti virus scan on the files I am uploading in PHP application and return virus found or not.

if found then delete the file else load scanned file into "Scanned" folder.

 

I am trying exec() function but not sure how to pass data file path to exec() function.

I am using:

<?php

$tmp = exec("C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe  C:\48 SchemeTemplate.xls", $results);

echo "Result: " . $results;

?>

Can someone please help me.

Many thanks for your time,

ND ::)

Link to comment
https://forums.phpfreaks.com/topic/199756-antivirus-scan-during-uploading-a-file/
Share on other sites

I've never used McAfee on the command line, but if you look it up. I'm pretty sure you need to pass in the file name of what you're scanning, and surrounded in quotes if it contains spaces in the directory/filename.

 

Also, are you aware if scan32.exe will produce any output?

csscan.exe is thecommand line application. I have ran in cmd and the summary section is what I am after (see attachment).

 

Here are the codes I am using:

<?php

echo "start scanning...";

$return = array();

$tmp = exec("C:\Program Files\McAfee\VirusScan Enterprise\csscan.exe  /c C:\48SchemeTemplate.xls", $return);

 

foreach( $return as $line )

{

    echo $line,"\n\n";

}

echo "scanning done.";

?>

 

[attachment deleted by admin]

Ah, I can't believe I didn't notice!

 

In your exec. You have backslashes, these need to be escaped like so:

 

 <?php
echo "start scanning...";
$return = array();
$tmp = exec("C:\\Program Files\\McAfee\\VirusScan Enterprise\\csscan.exe  /c C:\\48SchemeTemplate.xls", $return); // Double backslash is needed to escape them

foreach( $return as $line )
{
    echo $line,"\n\n";
}
echo "scanning done.";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.