I have a column in a MySQL database called photo of type mediumblob and it can be NULL.
This should represent a small photo of an employee displayed in the top right corner of web application.
The new employee is inserted via a form to MySQL database.
<form action="insert" method="post" enctype="multipart/form-data">
   ...
   <label for="photo">Photo</label>
   <input type="file" name="photo">
   ...
</form>
The photo will be validated as follows:
- It can be unuploaded (no photo will be provided in the form) - else if some photo is provided 
- It should be of image type 
- The image size should be suitable size for this purpose 
- The dimensions of the image should be suitable for this purpose 
Here is the outline of my validation code so far. I have already created some validation conditions (1 and 2). Are those OK? And don't know how to create conditions 3 and 4.
$file = $_FILES['photo']['tmp_name']
if (!isset($file))
{
    $image = ""; // 1), empty string will be inserted into the database
}
else {
    $image = addslashes(file_get_contents($_FILES['photo']['tmp_name']));
    $image_size = getimagesize($_FILES['photo']['tmp_name']);
    if ($image_size == FALSE) { 
      // 2) not an image file
      // display the form again with error message
    }
    // checking 3)
    // checking 4)
}
 
     
     
     
     
     
     
    