} // FULL FILE if (isset($_FILES['prestaebooks_' . $file_type]['tmp_name'])) { $mime_type = PrestaEbooksUpload::getMimeType($_FILES['prestaebooks_' . $file_type]['tmp_name']); if (in_array($mime_type, $allowed_mime_types)) { $new_filename = $product_id . '.' . $file_type; $new_path = $upload_dir . $file_type . '/'; $full_path = $upload_path . $file_type . '/' . $new_filename; if (move_uploaded_file($_FILES['prestaebooks_' . $file_type]['tmp_name'], $full_path)) { // unzip epub if ($mime_type == 'application/epub+zip') { $unzip_dir = dirname(__FILE__) . '/../../ebook_files/unzip/'; $unzip_filename = str_replace('.epub', '.zip', $new_filename); $unzip_path = $unzip_dir . $unzip_filename; copy($full_path, $unzip_path); $unzip_dir = PrestaEbooksEpub::unzipEpub($unzip_filename, $file_type, 'unzip'); if ($unzip_dir !== false) { // read table of contents $ebook_toc = PrestaEbooksEpub::getToc($unzip_dir); } else { die('unzip failed'); } // remove zip directory PrestaEbooksEpub::removeUnzipDir($unzip_dir); } // read mobi metadata if ($mime_type == 'application/octet-stream') { if (PrestaEbooksMobi::isMobiFile($full_path) == false) { die('file is not a valid mobi file'); } }