Php file upload problems

Source: Internet
Author: User
I used php to write a simple page for uploading php files. it shows that the file has been uploaded successfully, but (1) files not uploaded under the corresponding directory [no files under the tmp directory, and no upload directories and files are generated ]. (2) parameter order of move_uploaded_file. the previous line in the code is incorrect, and the next line is correct, which is the opposite of that in the textbook. Solve the php file upload problem
I used php to write a simple file upload page, which shows that the upload is successful,
(1) files not uploaded in the corresponding directory [no files in the tmp directory, and no upload directories and files are generated ].
(2) parameter order of move_uploaded_file. the previous line in the code is incorrect, and the next line is correct, which is the opposite of that in the textbook.

Please try again.

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 "];
}


}



?>


Running result:
Upload: d.txt
Type: text/plain
Size: 2.439213125kb
Stored in: E: \ wamp \ tmp \ php4A7. tmp



Storeed in: upload/d.txt files uploaded by php are not generated and shared:
------ Solution --------------------
Move_uploaded_file returns a value. Check whether the method is successfully executed.

Path exists?

Write permission?
------ Solution --------------------
Does the current directory have an upload directory? You can create one first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.