A problem encountered when uploading php files (move_uploaded_file)

WBOY
Release: 2016-07-25 09:04:30
Original
1255 people have browsed it
When uploading PHP files, you cannot use the move_uploaded_file function to move the file, but you can use copy or rename.

When uploading PHP files, you cannot use the move_uploaded_file function to move the file, but you can use copy or rename. The documentation is rather vague, but the function move_uploaded_file adds a step to check whether the file was uploaded via HTTP POST. Later, I finally saw in the source code that the file name was compared 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 the PHP configuration file is parsed, 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.

Also, please note that if move_uploaded_file is configured as an inaccessible path, no matter how you handle it, move_uploaded_file will never successfully move the file.



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