security check for a pdf file during upload in php -
this question has answer here:
- authenticity of uploaded pdf files 1 answer
i trying check pdf before upload.
i want check pdf malicious or not.
for example: save php file pdf , upload it. server shows error not valid pdf.
so how can check pdf real or not in php?
please see fileinfo extension php: http://www.php.net/fileinfo example of usage here: http://www.php.net/manual/en/function.finfo-open.php
l.e: please note, fileinfo way should check file types. not use extensions check against file type, huge mistake.
also, if fileinfo not available reason , cannot install , have shell access, can : $info = exec('file -ib ' . escapeshellarg($filepath)); print_r($info);