Alright so I edited my code to look like this, but I think I may have misunderstood vividona's instructions. I now have a form on two pages instead of one, does that make sense? It sure doesn't to me, but here is what I have:
upav.php (the file selection page)
<html>
<head>
<Title>Avatar Selection</Title>
</head>
<body>
<center>
Select an avatar to upload. <br><br><br><br>
<form action="uploadav.php" method="post" enctype="multipart/form-date">
<input type="file" name="file" size="50"><br>
<input type="submit" value="Upload Avatar">
</form></p><br><br>
</body>
</html>
uploadav.php ( the processing script)
if(isset($_POST['submit'])){
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
}else{
echo"Select an avatar to upload. <br><br><br><br>,
<form action="uploadav.php" method="files" enctype="multipart/form-date">
<input type="file" name="file" size="50"><br>
<input type="submit" value="Upload Avatar">
</form></p><br><br>";
}
?>
<html>
Error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\Pkshost0\uploadav.php on line 65
As far at that enctype="multipart/form-date" , I am using a book to help me learn php, "PHP In Easy Steps" and it seems that a lot of it's syntax is outdated 🙁 . Please let me know the proper syntax so I can know the right way to do it.