I usually call ClamAV when accepting files that can be shared. With PHP, this is pretty easy to accomplish using php-clamav .
One of the last things you want to do is distribute malware all over the world :)
If you can, do it in the background after the file is downloaded, but before you make it public. The oddity with this class is that it can load the entire ClamAV virus definition database into memory, which almost certainly stinks if PHP runs under Apache conditionally (think about +120 MB of memory per instance).
Using something like beanstalkd to scan downloads and then update your database to make them public, this is a very good way to get around this.
I mentioned this only because there were no other answers, I did not want this to be a complete solution. See Other Answers posted here, this is the step you should end with. Always, always, always sanitize your entrance, make sure it is of the expected type, etc. (I mentioned that you should also read other answers?)
Tim post
source share