Jump to content

PHP File Upload


matlyn

Recommended Posts

I have the following code in my php file that handles a user photo from a HTML upload page.  I am using the code below to see if they are attempting to upload a file other than a jpg file:

 

...

 

$userfile_type = $_FILES['image']['type'];

     

// Check to see if uploaded image is a jpg

if($userfile_type != "image/pjpeg"){

                ...etc

 

I have had many users upload jpg files without a problem but some users will fail this test (i.e. the file they are uploading is not recognized as a jpg file).  However, if they email me the jpg photo and I upload the exact same file, no problem.

 

This makes me think that it is a browser problem.  I am using IE7.  Do you think that the browser is the place to look for my users problems or what?

Link to comment
Share on other sites

You should put in these:

 

$userfile_type = $_FILES['image']['type'];

   

    // Check to see if uploaded image is a jpg

    if($userfile_type != "image/pjpeg" || $userfile_type != "image/jpeg" || $userfile_type != "image/jpg"){

                ...etc

 

or make a javascript which checks the browser and tell the user that he or she have to install IE7 to be able to upload images.

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.