Jump to content

[SOLVED] Yet another script that works in Firefox and not IE


bluedaniel

Recommended Posts

This is an picture upload script that works in Firefox but not IE.

 

Im only uploading a part of the script that I think is the culprit, if you need to see more I will oblige

 

The error in IE is "Im sorry you can only upload a JPG which is under 1MB in size" which is outputted at the end of the script.

 

<?php
  if (isset($_POST['upload'])) {
      if (isset($_FILES['uploaded_pic'])) {
          $id = $_POST['recipeID'];
          $filename = basename($_FILES['uploaded_pic']['tmp_name']);
          $ext = substr($filename, strrpos($filename, '.') + 1);
          if (($_FILES["uploaded_pic"]["type"] == "image/jpeg") && ($_FILES["uploaded_pic"]["size"] < 1000000)) {

                    //Code not uploaded

              } else {
              $message = "Im sorry you can only upload a JPG which is under 1MB in size.";
          }
      }
  }
?>

 

any ideas?

When a comparison fails, examine what the actual value is that failed. Echo out $_FILES["uploaded_pic"]["type"] to find what IE puts in it for the file type (different browsers send different mime types for the same file.)

excellent! Thank you so much.

 

Working (and now universal!) code:

 

$filetype = $_FILES["uploaded_pic"]["type"];
	  $acceptablefiletypes = array("image/pjpeg", "image/jpeg", "image/jpg");
          if (in_array($filetype, $acceptablefiletypes) && ($_FILES["uploaded_pic"]["size"] < 1000000)) {

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.