Home > Article > Backend Development > The problem that move_uploaded_file cannot move files when uploading php files
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. |