Php file upload problems

Source: Internet
Author: User
Tags php file upload
Php file upload problems php file upload does not generate files and directories

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
 0) {echo "Error:". $ _ FILES ["file"] ["error"]."
";} Else {echo" Upload: ". $ _ FILES [" file "] [" name "]."
"; Echo" Type: ". $ _ FILES [" file "] [" type "]."
& Quot; echo & quot; Size: & quot;. ($ _ FILES [& quot; file & quot;] [& quot; size & quot;]/1024). & quot; 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


Reply to discussion (solution)

Great God saved me ~~~~~~~~~~~~~~~~~~~~ ·

What is the error reported in the previous sentence?

Move_uploaded_file returns a value. Check whether the method is successfully executed.

Path exists?

Write permission?

What is the error reported in the previous sentence?
Warning: move_uploaded_file (upload/d.txt) [function. move-uploaded-file]: failed to open stream: No such file or directory
Warning: move_uploaded_file () [function. move-uploaded-file]: Unable to move 'E: \ wamp \ tmp \ php4D5. tmp 'to 'upload/d.txt'

Move_uploaded_file returns a value. Check whether the method is successfully executed.

Path exists?

Write permission?
I tried it. the returned value is false.

Does the current directory have an upload directory? You can create one first.

Does the current directory have an upload directory? You can create one first.
Thank you. I have created the upload directory under the current directory (an error occurred before, and an uploaded Directory was created) and run the previous statement. The result is correct.

Move_uploaded_file returns a value. Check whether the method is successfully executed.

Path exists?

Write permission?
After the directory is created, it runs correctly. thank you.

Does the current directory have an upload directory? You can create one first.
However, no temporary files are generated in the E: \ wamp \ tmp \ directory.


Does the current directory have an upload directory? You can create one first.
However, no temporary files are generated in the E: \ wamp \ tmp \ directory.
Depends on the configuration. Check which Directory the configuration is in. Phpinfo

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.