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
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";
  }
?>

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.