A problem with file uploads in PHP

  • 2020-03-31 21:04:48
  • OfStack

I've been confused, too. On the document, it's a little bit more vague, it's move_uploaded_file, and it's just a little bit more of a check to see if this file has an HTTP POST,


As for how to check, it is not said.


I googled for a while, but I couldn't solve the problem, and I didn't know where it was. Finally, I decided to look at the source code. Finally in the source code to see the file name and


Upload_tmp_dir in the PHP configuration is a comparison parameter. If the file is under this directory, then move_uploaded_file will be moved. And the comparison is case sensitive and / \ is different under Windows. And when the PHP configuration file is parsed, it's going to call a realpath function, which says, before you go to move_uploaded_file,


Must be $file [' tmp_name '] = realpath ($file [' tmp_name ']); Realpath.


The other thing to note is that if move_uploaded_file is configured as an unreachable path, then whatever you do, move_uploaded_file will never move the file.

Related articles: