Simple PHP file Upload instance. Copy the code as follows :? Phpif ($ _ FILES [file] [type] imagegif) | ($ _ FILES [file] [type] imagejpeg) | ($ _ FILES [file] [type] imagepjpeg) ($ _ FILES [
The code is as follows:
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"]."
";
}
Else
{
Echo "Upload:". $ _ FILES ["file"] ["name"]."
";
Echo "Type:". $ _ FILES ["file"] ["type"]."
";
Echo "Size:". ($ _ FILES ["file"] ["size"]/1024). "Kb
";
Echo "Temp file:". $ _ 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"]); // comment
Echo "Stored in:". "upload/". $ _ FILES ["file"] ["name"];
}
}
}
Else
{
Echo "Invalid file ";
}
?>
This is because a temporary folder exists in the PHP file during Upload. if the temporary file is not moved, the temporary file will be automatically deleted after the script is complete.
Therefore, the above line of code is to save the uploaded file. The saved directory is the upload folder under the current directory.
The http://www.bkjia.com/PHPjc/824899.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/824899.htmlTechArticle code is as follows :? Php if ($ _ FILES ["file"] ["type"] = "image/gif ") | ($ _ FILES ["file"] ["type"] = "image/jpeg ") | ($ _ FILES ["file"] ["type"] = "image/pjpeg") ($ _ FILES ["...