After successfully creating a Registration/Signin/user profile... now I am assigning a profile picture for a user ... I have a question... Everytime I hit upload it doesnt upload I added an "echo' to say if no file is chosen "Please Select a file", it shows this even when I select a file.. here is my code:
<?php
Session_start();
include("database.php");
$Id = $_SESSION['Id'];
$sql=("SELECT * FROM Persons WHERE Id ='$Id'");
$result=mysql_query($sql);
$data = mysql_fetch_array($result);
$_SESSION['Id'] = $data['Id'];
$_SESSION['Email'] = $data['Email'];
$_SESSION['FirstName'] = $data['FirstName'];
if ($_POST['submit'])
{
$name = $_FILES['myfile']['name'];
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
//start upload
$location = "avatars/$name";
move_uploaded_file($tmp_name,$location);
$query = mysql_query("UPDATE Persons SET imagelocation='$location' WHERE Id ='$Id'");
die("Your Profile Picture has been uploaded! <a href='member.php'>Back to Profile</a>");
}
else
die("Please Select a File!");
}
echo "Welcome, ".$_SESSION['FirstName']."!<p>";
echo "Upload Your Profile Image:";
?>
<HTML>
<Body>
<form action="upload.php" method="POST" ectype="multipart/form-data">
File: <input type="file" name="myfile">
<input type="submit" value="Upload!" name="submit">
</form>
<Body/>
</HTML>