The move_uploaded_file() function moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
Syntax
move_uploaded_file(file_path, moved_path)
Parameters
file_path − The file to be moved.
moved_path − Where the file will be moved.
Return
The move_uploaded_file() function returns true on success and false on failure.
Example
<?php
if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/documents/new/")) {
print "Uploaded successfully!";
} else {
print "Upload failed!";
}
?>Output
Upload failed!PHP Notice: Undefined index: userfile in /home/cg/root/8944881/main.php on line 2