Dymanically running ClamAV's clamscan on file uploads with PHP
Stack,

I want to scan each file that gets uploaded via my php upload script with clam anti-virus's clamscan tool.  I think I've got a good script written but I wanted to run it past you guys.

So assuming that the file I'm sending to this php upload script is named "uploadedfile" does the following code make sense?

    <?php
    
    $safe_path = escapeshellarg('/tmp/' . $_FILES['uploadedfile']['tmp_name']);
    $command = 'clamscan ' . $safe_path;
    $out = '';
    $int = -1;
    exec($command, $out, $int);
    
    if ($int == 0) {
       // all good, code goes here uploads file as normal IE move to
    permanent directory etc;
    } else {
       unlink('/tmp/' . $_FILES['uploadedfile']['tmp_name']);
    header(Location: http://www.domain.com/uploadform.php?error=your-file-was-infected-pal);
    }
    
    ?>

Also, will clamscan find php shells as well as traditional good old malware?

Thanks!
Dymanically running ClamAV's clamscan on file uploads with PHP
===

Stack,

I want to scan each file that gets uploaded via my php upload script with clam anti-virus's clamscan tool.  I think I've got a good script written but I wanted to run it past you guys.

So assuming that the file I'm sending to this php upload script is named "uploadedfile" does the following code make sense?

    <?php
    
    $safe_path = escapeshellarg('/tmp/' . $_FILES['uploadedfile']['tmp_name']);
    $command = 'clamscan ' . $safe_path;
    $out = '';
    $int = -1;
    exec($command, $out, $int);
    
    if ($int == 0) {
       // all good, code goes here uploads file as normal IE move to
    permanent directory etc;
    } else {
       unlink('/tmp/' . $_FILES['uploadedfile']['tmp_name']);
    header(Location: http://www.domain.com/uploadform.php?error=your-file-was-infected-pal);
    }
    
    ?>

Also, will clamscan find php shells as well as traditional good old malware?

Thanks!