Jump to content

Works in Chrome but not IE


cmb

Recommended Posts

this is my upload script which i found on the www3school site

form:

<form method="post" action="prod_update.php" enctype="multipart/form-data">
<label for="product">Product : 
  <input type="text" id="product" name="product" value="<?php echo $row['Product']?>" />
</label>
</td></tr><tr><td>
  <label for="price">Price : 
  <input type="text" id="price" name="price" value="<?php echo $row['Price']?>" />
</label>
</td></tr><tr><td>
  <label for="file">Picture : 
   <input type="file" name="file" id="file" accept="image/*" />
  </label>
</td></tr><tr><td>
<input type="submit" value="Update" />
</td></tr>

</form>

 

upload script:

<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")))
//&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "../images/products/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "images/products/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

 

when i run this in chrome it works no problem but wen i run it in IE i get this


Notice: Undefined index: file in C:\xampp\htdocs\Register\admin\prod_update.php on line 2

Notice: Undefined index: file in C:\xampp\htdocs\Register\admin\prod_update.php on line 3

Notice: Undefined index: file in C:\xampp\htdocs\Register\admin\prod_update.php on line 4
Invalid file

Link to comment
https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/
Share on other sites

pod_mod.php (form page)

<?php
require("check_login.php");
echo "<h3><a href='products.php'>Go Back</a> | <a href='../login/logout.php'>Logout</a>";

$pid = mysql_real_escape_string($_POST['pid']);
$query = "SELECT * FROM products WHERE id='$pid'";
$results = mysql_query($query) or die("Query failed ($query) - " . mysql_error());
$row = mysql_fetch_array($results);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modify Products</title>
</head>

<body>
<center>
<table>
<tr><td><img src="../<?php echo $row['Path']?>" /></td></tr>
<tr><td>
<form method="post" action="prod_update.php" enctype="multipart/form-data">
<label for="product">Product : 
  <input type="text" id="product" name="product" value="<?php echo $row['Product']?>" />
</label>
</td></tr><tr><td>
  <label for="price">Price : 
  <input type="text" id="price" name="price" value="<?php echo $row['Price']?>" />
</label>
</td></tr><tr><td>
  <label for="file">Picture : 
   <input type="file" name="file" id="file" accept="image/*" />
  </label>
</td></tr><tr><td>
<input type="submit" value="Update" /> <input type="button" value="Delete" onclick="del();" />
</td></tr>

</form>
</table>
</center>
</body>
</html>

 

prod_update.php (upload script)

<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")))
//&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "../images/products/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "images/products/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

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.