Home >Backend Development >PHP Tutorial >Upload A problem with file upload in PHP

Upload A problem with file upload in PHP

WBOY
WBOYOriginal
2016-07-29 08:43:42789browse

I've been confused too. The documentation is rather vague. It is the function move_uploaded_file that adds a step to check whether the file was uploaded via HTTP POST.
As for how to check, it is not mentioned.
I googled for a while, but I couldn’t solve this problem, and I don’t know where the problem lies. Later, I finally decided to look at the source code. Finally, I saw in the source code that the file name is 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 you move_uploaded_file, you must set $file['tmp_name'] = realpath($file['tmp_name']); realpath.
There is another situation that everyone should pay attention to, that is, if move_uploaded_file is configured as an inaccessible path, then no matter how you handle it, move_uploaded_file will never successfully move the file.
The above has introduced a problem in uploading files in PHP, including uploading content. I hope it will be helpful to friends who are interested in PHP tutorials.

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