In PHP, uploading files to a server is a simple process. PHP makes it easier to upload files to a server by providing some unique features. PHP allows you to upload single or multiple files with ease. PHP allows you to upload both binary and text files. Other functions and methods in PHP can be used to check and control the features associated with file uploading, such as determining the file size and type, or moving the uploaded file to a new location.
PHP move_uploaded_file() Function
To move an uploaded file to a new location, use the PHP move uploaded file() function.
The PHP move uploaded file() function only moves files that have been uploaded via HTTP POST.
The PHP move uploaded file() function either creates a new file or overwrites an existing file at the destination.
If the file is successfully moved, the PHP move uploaded file() function returns TRUE; otherwise, it returns FALSE if the process of moving the uploaded file to a new destination fails.
$target_dir = "php_programs/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file))
echo "The file uploaded";
echo "File not uploaded";
The file uploaded