Move_uploaded_file failed to open stream error handling

WBOY
Release: 2016-07-29 09:02:05
Original
2265 people have browsed it

I have almost learned the basic syntax of PHP, now I am starting to learn how to implement the file upload function of PHP. The move_uploaded_file method is used in the function, and an error is reported when running: failed to open stream.
After checking the information, I summarized several possible reasons and solutions for this error.

Reason 1: The writing of the directory to be moved is incorrect

My directory is as follows:
move_uploaded_file的failed to open stream错误处理
This is an example from the fourth edition of "PHP and MySQL Web Development". My PHP version is 7.0.2, and a failed to open stream error occurred when executing it. There are two solutions to this error: first, write an absolute path, such as "D:/uploads/"; second: when using a relative path, use "./uploads/" to move the file to the uploads directory under the current default directory. or use "../uploads/" to move the file to the uploads directory under the parent directory of the current directory.

Cause 2: The directory you moved to does not exist

If the directory you moved to does not exist, a failed to open stream error will also be reported. Creating the corresponding directory can solve the problem.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the failed to open stream error handling of move_uploaded_file, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!