if ($_FILES['imagedata']['size'] > 0) {
         $fileName = $_FILES['imagedata']['name'];
         $tmpName = $_FILES['imagedata']['tmp_name'];
         $fileSize = $_FILES['imagedata']['size'];
         $fileType = $_FILES['imagedata']['type'];
         //
         // check the uploaded file is actually an image.
         //
         $file_info = getimagesize($tmpName);
         if (!empty($file_info)) {
             $fp = fopen($tmpName, 'r');
             $imgbytes = fread($fp, filesize($tmpName));
             fclose($fp);
         }
     }
     $tvinfo->add($_POST["rageID"], $_POST["tvdbID"], $_POST["mazeID"], $_POST["releasetitle"], $_POST["description"], $_POST["genre"], $_POST['country'], $imgbytes);
 } else {
     $imgbytes = "";
     if ($_FILES['imagedata']['size'] > 0) {
         $fileName = $_FILES['imagedata']['name'];
         $tmpName = $_FILES['imagedata']['tmp_name'];
         $fileSize = $_FILES['imagedata']['size'];
         $fileType = $_FILES['imagedata']['type'];
         //
         // check the uploaded file is actually an image.
         //
         $file_info = getimagesize($tmpName);
         if (!empty($file_info)) {
             $fp = fopen($tmpName, 'r');
             $imgbytes = fread($fp, filesize($tmpName));
             fclose($fp);