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
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?

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.