Last active
March 22, 2022 09:09
-
-
Save andybeak/3817d12fb94af49b3d6037c2f0eca134 to your computer and use it in GitHub Desktop.
Clamscan PHP uploads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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