What are some common pitfalls to be aware of when handling file uploads in PHP?

One common pitfall when handling file uploads in PHP is not properly validating the file type and size before processing it. This can lead to security vulnerabilities such as allowing users to upload malicious files or consuming excessive server resources. To mitigate this, always validate the file type using the `$_FILES['file']['type']` and `$_FILES['file']['size']` variables before moving or processing the uploaded file.

if ($_FILES['file']['type'] != 'image/jpeg' || $_FILES['file']['size'] > 5000000) {
    // Invalid file type or size
    echo "Invalid file. Please upload a JPEG image under 5MB.";
} else {
    // Process the file
    move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
    echo "File uploaded successfully.";
}