What potential pitfalls should be considered when moving uploaded files to a specific directory in PHP?

When moving uploaded files to a specific directory in PHP, potential pitfalls to consider include ensuring proper file permissions are set on the destination directory, checking for existing files with the same name to avoid overwriting them, and validating file types to prevent malicious uploads. It's also important to sanitize file names to prevent directory traversal attacks.

$uploadDir = 'uploads/';
$uploadFile = $uploadDir . basename($_FILES['file']['name']);

// Check if the file already exists
if (file_exists($uploadFile)) {
    echo "File already exists. Please choose a different file.";
} else {
    // Move the uploaded file to the destination directory
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
        echo "File is valid, and was successfully uploaded.";
    } else {
        echo "Upload failed. Please try again.";
    }
}