So I have a file upload portion on my website where the user can upload any doc or docx folder. Heres my html code:
You are uploading file to directory that does not exist so you need to create it first, your upload_file.php should be like
0)
{
echo "Return Code: " . $_FILES["upload"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["upload"]["name"] . "
";
echo "Type: " . $_FILES["upload"]["type"] . "
";
echo "Size: " . ($_FILES["upload"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["upload"]["tmp_name"] . "
";
if (file_exists("Proposals/".$_SESSION["FirstName"] ."/" . $_FILES["upload"]["name"]))
{
echo $_FILES["upload"]["name"] . " already exists. ";
}
else
{
// Check if directory exists if not create it
if(!is_dir("Proposals/". $_SESSION["FirstName"] ."/")) {
mkdir("Proposals/". $_SESSION["FirstName"] ."/");
}
move_uploaded_file($_FILES["upload"]["tmp_name"],
"Proposals/". $_SESSION["FirstName"] ."/". $_FILES["upload"]["name"]);
echo "Stored in: " . "Proposals/". $_SESSION["FirstName"] ."/". $_FILES["upload"]["name"];
}
}
} else {
echo "Invalid file";
}
?>