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