if ($biblioQ->errorOccurred()) {
    $biblioQ->close();
    displayErrorPage($biblioQ);
}
if (!($biblio = $biblioQ->doQuery($bibid))) {
    $biblioQ->close();
    displayErrorPage($biblioQ);
}
// get image path
$imgname = $biblio->_biblioFields['902a']->_fieldData;
$imgpath = '../' . COVER_PATH . '/' . $imgname;
$thumbpath = '../' . COVER_PATH . '/' . 'thumb_' . $imgname;
if (file_exists($imgpath)) {
    chmod($imgpath, 666);
    // Windows platform compatibility, 666 is for "Nobody"
    unlink($imgpath);
}
if (file_exists($thumbpath)) {
    chmod($thumbpath, 666);
    unlink($thumbpath);
}
if (!$biblioQ->deleteCoverImage($bibid)) {
    $biblioQ->close();
    displayErrorPage($biblioQ);
}
$biblioQ->close();
if ($_GET['redirect'] == 'edit') {
    header("Location: ../catalog/biblio_edit.php?bibid=" . U($bibid) . "&msg=" . U($loc->gettext("This biblio's cover image has been removed.")));
} else {
    header('Location: ../shared/biblio_view.php?bibid=' . U($bibid) . "&msg=" . U($loc->gettext("This biblio's cover image has been removed.")));
}