cmb Posted July 15, 2012 Share Posted July 15, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/ Share on other sites More sharing options...
darkfreaks Posted July 15, 2012 Share Posted July 15, 2012 where in the code do you check if the form has been submitted i am not seeing it Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/#findComment-1361612 Share on other sites More sharing options...
cmb Posted July 15, 2012 Author Share Posted July 15, 2012 sorry the upload script is on a second page Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/#findComment-1361613 Share on other sites More sharing options...
darkfreaks Posted July 15, 2012 Share Posted July 15, 2012 can you post the full code please also you are missing semicolons after your echo's on the form Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/#findComment-1361614 Share on other sites More sharing options...
cmb Posted July 15, 2012 Author Share Posted July 15, 2012 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/#findComment-1361615 Share on other sites More sharing options...
cmb Posted July 15, 2012 Author Share Posted July 15, 2012 I figured out that IE will only upload files whose names only have letters in them Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/#findComment-1361708 Share on other sites More sharing options...
Pikachu2000 Posted July 15, 2012 Share Posted July 15, 2012 also you are missing semicolons after your echo's on the form They aren't needed there. Quote Link to comment https://forums.phpfreaks.com/topic/265693-works-in-chrome-but-not-ie/#findComment-1361713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.