Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
left right
Jetteh22
post Nov 22 2010, 06:07 PM
Post #1


PHP Programmer
*******

Group: Members
Posts: 895
Joined: 9-March 08
From: Naples, FL
Member No.: 13,296



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>
Go to the top of the page 
 
  + Quote Post

Posts in this topic

 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 24th May 2013 - 06:59 AM