The problem that move_uploaded_file cannot move files when uploading php files

WBOY
Release: 2016-07-25 09:00:58
Original
1224 people have browsed it
When implementing file upload in PHP, the file cannot be moved when encountering move_uploaded_file. Here is a solution for your reference.

php uploads files, and finally uses move_uploaded_file to move the file, but it doesn't work anymore, copy or rename is still normal

As seen in the source code, compare the file name with the upload_tmp_dir parameter in the PHP configuration. If the file is in this directory, then move_uploaded_file will perform the move operation. Moreover, this comparison is case-sensitive, and / is also different under Windows. When parsing the PHP configuration file, a realpath function will be called. That is to say, before move_uploaded_file, you must set $file['tmp_name'] = realpath($file['tmp_name']); realpath.

In addition, please note that if move_uploaded_file is configured to an inaccessible path, move_uploaded_file will always fail to move the file successfully.



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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template