Help - Search - Members - Calendar
Full Version: Php & Internet Explorer 2
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
Jetteh22
Like I said in my other one.. This code works great on Firefox and Chrome but not IE. Can't figure out why. It's supposed to verify the file is a gif,jpg or png and then upload it if it IS and give an error if it's not. If you'll notice, there are two ways it can fail and the error the user gets (only in IE) is "Avatars must be .jpg, .gif or .png formats!" even if it IS. It won't let you upload anything. I tried JPG, PNG, GIF, etc.


CODE
<?php
session_start();
include 'g_includes.php';

if (($_FILES["avatarfile"]["type"] == "image/gif")
  || ($_FILES["avatarfile"]["type"] == "image/jpeg")
  || ($_FILES["avatarfile"]["type"] == "image/png" ))
{

$targetpath = "useravatars/";

$targetpath = $targetpath . $g_userid . ".jpg"; //Yes, I know I am adding a .jpg to the end of it no matter what but this wouldn't be the problem.

if(move_uploaded_file($_FILES['avatarfile']['tmp_name'], $targetpath)) {

$sql = "UPDATE users SET avatar='$targetpath' WHERE id='$g_userid'";
mysql_query($sql) or die("Couldn't upload!");

$message = "Your new avatar has been uploaded! You might have to refresh the page to see it.";
$sql = "INSERT INTO news(userid,message) VALUES('$g_userid','$message')";
mysql_query($sql) or die("Couldn't insert message!");

}
else{
$message = "Unable to upload the file. ";
$sql = "INSERT INTO news(priority,userid,message) VALUES(2,'$g_userid','$message')";
mysql_query($sql) or die("Couldn't insert message!");

}
}
else{
$message = "Avatars must be .jpg, .gif or .png formats!";
$sql = "INSERT INTO news(priority,userid,message) VALUES(2,'$g_userid','$message')";
mysql_query($sql) or die("Couldn't insert message!");
}
?>

<script type="text/javascript">
// <!--
window.location = "g_account.php"
//-->
</script>
swordz
Try dumping out the contents of $_FILES - you'll find IE isn't setting the mime type correctly. My guess would be it's missing out the image/ part.

Swordz
martinadam13
Hello friends,

i am trying to remove extension from my inner pages ie. abc.com/books.php ---> to ----> abc.com/books. how can i convert this in php ?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.