Skip to content

Instantly share code, notes, and snippets.

@andybeak
Last active March 22, 2022 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybeak/3817d12fb94af49b3d6037c2f0eca134 to your computer and use it in GitHub Desktop.
Save andybeak/3817d12fb94af49b3d6037c2f0eca134 to your computer and use it in GitHub Desktop.
Clamscan PHP uploads
<?php
// Answer from https://stackoverflow.com/questions/7648623/dynamically-running-clamavs-clamscan-on-file-uploads-with-php
$safe_path = escapeshellarg($_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 {
//whatever you need to do if a virus is found.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment