Re: [PHP] Trapping for PDF Type and file size in a UPLOAD form...

[email protected] (tedd)
Newsgroups php.general
Message-ID <p06240801c8777202058d@[192.168.1.104]>
At 9:50 AM -0700 7/29/10, Don Wieland wrote:
>I am trying to create an UPLOAD form and need to figure a way to 
>only allow PDF files to be selected.

The short answer is you can't -- not from php. You can create a 
standard form and upload it from there, but you don't have control 
over file type.

So you can't stop people from uploading anything to your site via the 
form, but you can look at the document once it's there and inspect 
it. Using a HEX Editor, I see that most pdf file have the first four 
bytes as "%PDF" so you might check that before moving the file to 
somewhere important. But that doesn't stop spoofing.

Other than that, I can't see any way to do it.

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.