Hard time insert an image name into a directory with my custom code ...
I copied this bit from the same insert and other commands used to uplad the icons for the categories... but for some reason, the file is not being uploaded and the database is not being updated. Where did I go wrong with this?
PHP Code:
if ($_POST['featured_image_manual'] != '') { // add image manually
$featured_image_name = zen_db_input("news_box/" . $_POST['featured_image_manual']);
$db->Execute("update " . TABLE_BOX_NEWS . "
set news_image = '" . $featured_image_name . "'
where box_news_id = '" . (int)$box_news_id . "'");
} else {
if ($featured_news_image = new upload('featured_image')) {
$featured_news_image->set_destination(DIR_FS_CATALOG_IMAGES . "news_box/");
if ($featured_news_image->parse() && $featured_news_image->save()) {
$featured_image_name = zen_db_input("news_box/" . $featured_news_image->filename);
}
if ($featured_news_image->filename != 'none' && $featured_news_image->filename != '' && $_POST['image_delete'] != 1) {
// save filename when not set to none and not blank
$db->Execute("update " . TABLE_BOX_NEWS . "
set news_image = '" . $featured_image_name . "'
where box_news_id = '" . (int)$box_news_id . "'");
} else {
// remove filename when set to none and not blank
if ($featured_news_image->filename != '' || $_POST['image_delete'] == 1) {
$db->Execute("update " . TABLE_BOX_NEWS . "
set news_image = 'Something here?'
where box_news_id = '" . (int)$box_news_id . "'");
}
}
}
}
Re: Hard time insert an image name into a directory...
EDIT: The code seems to allow manual entry of filenames and the checkbox does work to clear out the name from the database. The only problem seems to be with the actual uploading.