Jump to content

PDF file type issue


chester

Recommended Posts

I test file type to only allow PDFs:

if ($_FILES["file"]["type"] == "application/pdf") {
move_uploaded_file($_FILES["file"]["tmp_name"],"sources/" . $_POST['fname']);
echo "<body onload=\"window.close()\">";
}

 

Users are reporting that occasionally PDFs will be rejected as not being PDFs. The users have sent me the files and they are valid PDFs that open in Adobe. Anyone else experience this before? Any suggestions for a solution?

Link to comment
https://forums.phpfreaks.com/topic/143556-pdf-file-type-issue/
Share on other sites

i haven't tried to upload PDF's before but diffrent browses could be sending different types

one one way to avoid it is to do a check like

if (strtolower(substr($_FILES["file"]["name"],strlen($_FILES["file"]["name"])-3)) == "pdf") {

it will check the file extension

 

Scott.

 

Link to comment
https://forums.phpfreaks.com/topic/143556-pdf-file-type-issue/#findComment-753233
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.