Move_uploaded_file failed to open stream error handling

Source: Internet
Author: User
PHP Basic Grammar learning almost, and now began to learn PHP file upload function implemented. The function is used in the Move_uploaded_file method, run The Times wrong: failed to open stream.
After checking the data, this paper summarizes several possible causes and solutions of the error.

Reason one: The directory you moved to is not spelled correctly

My directory is as follows:

This is the example in the fourth edition of PHP and MySQL Web development, and my PHP version is 7.0.2, which executes the times failed to open stream error. There are two workarounds for this error: The first is the absolute path, such as "d:/uploads/", and the second: when using a relative path, use "./uploads/" to indicate that the file is moved to the uploads directory under the current default directory, or use ". /uploads/"indicates that the file is moved to the uploads directory under the parent directory of the current directory.

Reason two: The directory moved to does not exist

The failed to open stream error will also be reported if the directory that you moved to does not exist. Creating a corresponding directory solves the problem.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('

  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the Move_uploaded_file failed to open stream error handling, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

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