ok so i made an avatar uploader and everything works fine but when you upload it it gives me an "xe'd out image. they open fine when you open them through the "index of/" though. heres the code for my "upload.php":
<?php
include("connect.php");
$_SESSION['username']="matt";
$username = $_SESSION['username'];
if ($_POST['submit'])
{
//get file attributes
$name = $_FILES['myfile']['name'];
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
//start upload process
$location = "avatars/$name";
move_uploaded_file($tmp_name,$location);
$query = mysql_query("UPDATE usersavatar SET imagelocation='$location' WHERE username='$username'");
die("Your avatar has been uploaded! <a href='view.php'>Home</a>");
}
else
die("Please select a file!");
}
echo "Welcome, ".$username."!<p>";
echo "Upload your image:
<form action='upload.php' method='POST' enctype='multipart/form-data'>
File: <input type='file' name='myfile'> <input type='submit' name='submit' value='Upload!'>
</form>
";?>
========================================================
and here's "view.php" where the image is supposed to appear when it uploaded:
<?php
include("connect.php");
$username = $_SESSION['username'];
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
if (mysql_num_rows($query)==0)
die ("User not found!");
else
{
$row = mysql_fetch_assoc($query);
$location = $row['imagelocation'];
echo "<img src='$location' width='100' height='100'>";
}
?>