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>
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>