How can one specify a specific directory on the server for file uploads in PHP?

When uploading files in PHP, you can specify a specific directory on the server by setting the "upload_path" parameter in the move_uploaded_file() function. This allows you to control where the uploaded files are stored on the server, providing security and organization for your file uploads.

$upload_dir = '/path/to/upload/directory/';
$upload_file = $upload_dir . basename($_FILES['file']['name']);

if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) {
    echo "File uploaded successfully!";
} else {
    echo "Error uploading file.";
}