Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Images disapearing when editing Catagories


DeadScary

Recommended Posts

Hi folks

 

I have a issue when editing the catagories. After doing my edit I click save and all seems to work fine. However if I had an image already assigned to that catagory it forgets the image and I get a message saying "Image dosen't exist". It's starting to annoy me as I don't want to have to upload the image everytime I edit the catagory.

 

Please Help

Link to comment
Share on other sites

Hi folks

 

I have a issue when editing the catagories. After doing my edit I click save and all seems to work fine. However if I had an image already assigned to that catagory it forgets the image and I get a message saying "Image dosen't exist". It's starting to annoy me as I don't want to have to upload the image everytime I edit the catagory.

 

Please Help

 

Is it doing the same thing with Manufacturers images ? I just posted a topic because I'm trying to find a solution to this myself.

 

http://www.oscommerce.com/forums/index.php?showtopic=249832

 

I'm hoping I've traced down the problem although I'm not sure I've got the experience to just whip out the solution.

 

Travis

Link to comment
Share on other sites

Ok I've fixed the categories so you can now edit them without having to upload the image each time. Just a couple of edits and it's working for me.

 

Here is what I did. (remeber to backup your files before you try it)

 

Open admin/categories.php

 

Replace this code around line 80 - 82

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 . "'");

}

 

With

 

// If no image set allow upload and setting of new image

if ($HTTP_POST_VARS['categories_image2'] == ''){

$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 . "'");

}

//if image is set and image update is checked then upload new image

if (($HTTP_POST_VARS['categories_image2'] != '') && ($HTTP_POST_VARS['newimage'] == 'Y')) {

$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 . "'");

}

 

Next after this line (around 905)

$contents[] = array('text' => '<br>' . TEXT_EDIT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image'));

 

Add this

$contents[] = array('text' => '<br>Update Image<br>' . tep_draw_checkbox_field('newimage', Y));

$contents[] = array('text' => tep_draw_hidden_field('categories_image2',$cInfo->categories_image));

 

In simple terms upload images as normal. You can now edit the category without loosing the image. If you wish to update the image just browse for it as normal and check the update image box.

 

I'm sure there are neater ways of doing this but it's working and that's the main thing.

Link to comment
Share on other sites

Ok I've fixed the categories so you can now edit them without having to upload the image each time. Just a couple of edits and it's working for me.

 

 

I'm sure there are neater ways of doing this but it's working and that's the main thing.

 

Thanks for taking a look at this. I've been slammed to the wall on another project and this is the first chance I've had to check in on this in a week .

 

Did you get a chance to look at the Manufacturers code at all? I'm going to give your code a try as I've got the same problems happening with my Cate. and Manu. admin areas.

 

Thanks Again

Travis

Link to comment
Share on other sites

Thanks for taking a look at this. I've been slammed to the wall on another project and this is the first chance I've had to check in on this in a week .

 

Did you get a chance to look at the Manufacturers code at all? I'm going to give your code a try as I've got the same problems happening with my Cate. and Manu. admin areas.

 

Thanks Again

Travis

 

Haven't had a chance to have a look yet, not a high priorty for me on this project but will have a look when I get the chance

Link to comment
Share on other sites

Ok I've fixed the categories so you can now edit them without having to upload the image each time. Just a couple of edits and it's working for me.

 

 

I'm sure there are neater ways of doing this but it's working and that's the main thing.

 

Just wanted to say a quick thanks. Your code fixed the problem

 

Travis

Link to comment
Share on other sites

find the same lines of code in admin/manufacturers.php as above for categories and your code works perfect there as well just change "categories" to "manufacturers" throughout

 

near line 45-50

// If no image set allow upload and setting of new image 
if ($HTTP_POST_VARS['manufacturers_image2'] == ''){
$manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES);
tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . tep_db_input($manufacturers_image->filename) . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
} 
//if image is set and image update is checked then upload new image
if (($HTTP_POST_VARS['manufacturers_image2'] != '') && ($HTTP_POST_VARS['newimage'] == 'Y')) { 
$manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES);
tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . tep_db_input($manufacturers_image->filename) . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
}

near line 250ish

$contents[] = array('text' => '<br>Update Image<br>' . tep_draw_checkbox_field('newimage', Y));
$contents[] = array('text' => tep_draw_hidden_field('manufacturers_image2',$mInfo->manufacturers_image));

 

Thanks again

Travis

Link to comment
Share on other sites

  • 5 months later...

Here is a simpler fix:

 

if($_FILES['manufacturers_image']['name'] != '')
{
	if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES)) {
	  tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
	}
}

 

 

You can do the same for catalog images.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...