anonymous
2011-04-28 05:42:30 UTC
Code for upload image file is here.
$_SESSION ['email'];
$email = $_SESSION['email'];
if (isset($_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 images SET imagelocation='$location' WHERE email='$email' ");
die ("Your profile image has been uploaded! Profile ");
}
else
die("Please select a file!");
}
echo "Welcome, ".$email."!
";
echo "Upload your image:
";
?>
and code for echo the image is here.
$error = "Unable to Connect.";
$connect = mysql_connect("localhost","root","") or die ($error);
mysql_select_db("phplogin") or die ($error);
$email = isset($_SESSION['email']);
$query = mysql_query("SELECT * FROM images WHERE email = '$email' ");
if(mysql_num_rows($query)==0)
die ("User not found!");
else
{
$row = mysql_fetch_assoc($query);
$location = $row['imagelocation'];
echo "
}
?>
It's time consuming I know. But if any one have any tutorial on this topic please just send me link.
Thanks in advance.