I\'m working on a script that allows users to download files stored online. It always seems to work with image files, but with PDF\'s the browser sometimes downloads .PHP fi
Adding ob_clean(); and flush(); functions before the readfile(); function, could be something worth using, as per what the PHP manual states on the subject.
readfile() http://php.net/manual/en/function.readfile.php
ob_clean() http://php.net/manual/en/function.ob-clean.php
flush() http://php.net/manual/en/function.ob-flush.php
These functions are not present in your posted code.