I've added some checks here to make sure that the image file that are uploaded are of the right extension as well as to check if the file was moved and trully inserted/uploaded into the database.