Community Add-Ons

Maintainers: lukec
Add file to this package
Top » Other

Image disappears after edit category fix
for osCommerce Online Merchant v2.2

Image disappears after edit category fix

When you edit a category and don't change the image for the category, then hit the save button, the image for the category disappears as the save button over writes the image with an empty string. I did look around for a fix to this, but could not find one anywhere. I did find a number of people wanting a fix for this problem. The fix is simple :-

In catelog/admin/categories.php find the line :-

if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
}

and replace it with :-

if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {
if (!is_null($categories_image->filename)) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
}
}

That's it. We simply check to see if the filename is an empty string and if it is, do not over write the existing filename.

I noticed the bug in a number of other areas, like the Manufactures list, Supplies list and so on. The fix is the same, but instead of using the variable $categories_image in the if statement, use the correct variable name for the file you are editing. Eg. for manufacturers.php use $manufacturers_image and so on.

Have fun!
lukec

Legend:  Download   Report
Expand All / Collapse All
original contrib is correct, ignore bottom post arkane8 14 Oct 2008  

The last contrib must've not been paying attention to the lines. Original contrib is correct.

No files attached

Error!! Extra } qwan 14 Jun 2007  
Image disappears after edit category fix lukec 17 May 2007