I'm still pretty new at PHP so I don't know the exact code you would take do this, but since PHP doesn't contain a virus scanner of it's own you'll have to use something external. Here are the general steps.
- First save the file to the file system somewhere instead of the database.
- Run an external program (like some linux virus scanner) to scan the file for viruses. And have it output some sort of error code or some sort of infected.log file or something.
- With PHP read and parse log file to check for virus marker.
- If not infected re-read file from file system and upload to database.
- If infected delete file using external commands, and send trigger a true false if statement somewhere to send the user to a "sorry your file is diseased" page.
Well this isn't much to go on for actually doing this, but it's a start.