// save the ebook try { $epub->save(); } catch (Exception $e) { $error = $e->getMessage(); } // clean up temporary cover file if ($cover) { @unlink($cover); } // rename $author = array_shift(array_keys($epub->Authors())); $title = $epub->Title(); $new = to_file($author . '-' . $title); $new = $bookdir . $new . '.epub'; $old = $epub->file(); if (realpath($new) != realpath($old)) { if (!@rename($old, $new)) { $new = $old; //rename failed, stay here } } $go = basename($new, '.epub'); header('Location: ?book=' . rawurlencode($go)); exit; } header('Content-Type: text/html; charset=utf-8'); ?> <html> <head> <title>EPub Manager</title>