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