PHP File Upload problem
I wrote a simple file upload page with PHP, showing that the upload was successful, but
(1), the corresponding directory but not uploaded files "tmp directory without files, and did not generate upload directories and files."
(2), move_uploaded_file parameter order, the code in the middle of the wrong line, the next line is correct, and the opposite of the textbook.
Ask the great God for doubts.
Upload.html
upload.php
if ($_files["file" ["error"] > 0)
{
echo "Error:". $_files["File" ["Error"]. "
";
}
Else
{
echo "Upload:". $_files["File" ["Name"]. "
";
echo "Type:". $_files["File" ["Type"]. "
";
echo "Size:". ($_files["File" ["Size"]/1024). " Kb
";
echo "Stored in:". $_files["File" ["Tmp_name"]. "
";
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"]);//Error
Move_uploaded_file ("upload/". $_files["File" ["Name"],$_files["file"] ["tmp_name"]);
echo "
Storeed in: "." upload/". $_files[" File "[" Name "];
}
}
?>
Operation Result:
Upload:d.txt
Type:text/plain
size:2.439453125kb
Stored in:e:\wamp\tmp\php4a7.tmp
Storeed In:upload/d.txt PHP Uploading Files no files and directories generated
Share to:
------Solution--------------------
The Move_uploaded_file will return a value. See if this method performs successfully.
Path exists?
Write permission?
------Solution--------------------
There is no upload directory under the current directory? It should be created first.