Jump to content

Checking if file is .pdf


Smudly

Recommended Posts

Hi,

I'm 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? I'm 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 I'm not sure how to go about this. Any insight appreciated!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.