PHP move_uploaded_file() Function
Definition and Usage
The move_uploaded_file() function moves the uploaded file to a new location.
Returns true if successful, otherwise returns false.
Syntax
move_uploaded_file(file,newloc)
Parameters | Description |
---|---|
file | Required. Specify the file to be moved. |
newloc | Required. Specify the new location of the file. |
Description
This function checks and ensures that file The specified file is a legitimate upload file (i.e., uploaded through PHP's HTTP POST upload mechanism). If the file is legitimate, it will be moved to the location specified by newloc the specified file.
If file It is not a legitimate upload file, no operation will occur, move_uploaded_file() will return false.
If file It is a legitimate upload file, but for some reason it cannot be moved, no operation will occur, move_uploaded_file() will return false, and a warning will also be issued.
This check is particularly important if there is a possibility that the uploaded file may cause the content to be displayed to users or other users of this system.
Tips and Comments
Comment:This function is used only for files uploaded via HTTP POST.
Note:If the target file already exists, it will be overwritten.