What are some common pitfalls when using PHP for creating a photo gallery?

One common pitfall when creating a photo gallery in PHP is not properly handling file uploads and ensuring that only image files are accepted. To solve this, you can use PHP's `$_FILES` superglobal to check the file type before processing the upload.

if(isset($_FILES['image'])){
    $file_name = $_FILES['image']['name'];
    $file_tmp = $_FILES['image']['tmp_name'];
    $file_type = $_FILES['image']['type'];
    
    $allowed_extensions = array('jpg', 'jpeg', 'png', 'gif');
    $file_extension = pathinfo($file_name, PATHINFO_EXTENSION);
    
    if(!in_array($file_extension, $allowed_extensions)){
        echo 'Only JPG, JPEG, PNG, and GIF files are allowed.';
    } else {
        // Process the image upload
    }
}