Search Webmaster Help and Solution

Checking if file is .pdf

Hi,
Im creating an upload section that limits users to upload the following file types:

.pdf
.zip
.rar
.doc
.jpeg
.gif

When getting the type for .pdf files, it comes up as:
application/force-download

and for .rar files it comes up as:
application/x-download

If I do a check that says:

if ($type=="application/force-download" || $type=="application/x-download")

then will users only be able to upload .PDF and .RAR files? Im assuming these two types will allow other formats as well.

If this is the case, how can I check the extension of the file before the user is able to upload it. I was thinking of somehow capturing the last 3 letters of the filename, and then doing the check that way, except Im not sure how to go about this. Any insight appreciated! Hi,
Im creating an upload section that limits users to upload the following file types:

.pdf
.zip
.rar
.doc
.jpeg
.gif

When getting the type for .pdf files, it comes up as:
application/force-download

and for .rar files it comes up as:
application/x-download

If I do a check that says:

if ($type=="application/force-download" || $type=="application/x-download")

then will users only be able to upload .PDF and .RAR files? Im assuming these two types will allow other formats as well.

If this is the case, how can I check the extension of the file before the user is able to upload it. I was thinking of somehow capturing the last 3 letters of the filename, and then doing the check that way, except Im not sure how to go about this. Any insight appreciated!

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).