PHP File Upload problem

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

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
 
  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


Reply to discussion (solution)

Come and save Me ~~~~~~~~~~~~~~~~~~~~

What's wrong with the last sentence?

The Move_uploaded_file will return a value. See if this method performs successfully.

Path exists?

Write permission?

What's wrong with the last 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 '

The Move_uploaded_file will return a value. See if this method performs successfully.

Path exists?

Write permission?
I tried, and the return value was false.

There is no upload directory under the current directory? It should be created first.

There is no upload directory under the current directory? It should be created first.
Thank you, I have built the upload directory in the current directory (previously built the wrong, built the uploaded), and run the previous sentence, the results run correctly.

The Move_uploaded_file will return a value. See if this method performs successfully.

Path exists?

Write permission?
After the catalog has been built, it runs correctly, thanks.

There is no upload directory under the current directory? It should be created first.
However, the appropriate temporary files are still not generated under the E:\wamp\tmp\ directory.


There is no upload directory under the current directory? It should be created first.
However, the appropriate temporary files are still not generated under the E:\wamp\tmp\ directory.
To see the configuration. See which directory is configured. Phpinfo

  • Related Article

    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.