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
https://forums.phpfreaks.com/topic/38353-php-file-upload/
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
https://forums.phpfreaks.com/topic/38353-php-file-upload/#findComment-183918
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.