Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Official Topic For 'change Default Image Directories' Contrib


Guest

Recommended Posts

the error message still says:

?

seems like it can't find the directory... but you're sure that it's correct?

 

What changes did the other mod make? did it change any of the parts around those which my contrib changes?

 

Yes I'm sure the directory is correct.

 

The other mod did not change anything around your mod.

This is the only difference in or around your instructions that I found.

 

Open: catalog/admin/categories.php

find (about line 80):

 

//your instructions find this code code to replace

 

if ($categories_image->parse() && $categories_image->save()) {

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

}

 

 

 

// this is the code in my page that I replaced (os commerce version 2.2)

 

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

}

 

:'(

Link to comment
Share on other sites

  • Replies 99
  • Created
  • Last Reply

Top Posters In This Topic

Yes I'm sure the directory is correct.

 

The other mod did not change anything around your mod.

This is the only difference in or around your instructions that I found.

 

Open: catalog/admin/categories.php

find (about line 80):

 

//your instructions find this code code to replace

 

if ($categories_image->parse() && $categories_image->save()) {

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

}

 

 

 

// this is the code in my page that I replaced (os commerce version 2.2)

 

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

}

 

:'(

 

As a test I changed the name of my folder from products to artists, also changed the config file to artist and the error message can't find artists so I know it's getting that far. Also tried changing the images folder name it is getting past images just cant seem to find the next folder??

 

Also tried a fix mentioned earlier

OPEN: catalog/admin/categories.php

find (about line 115):

Did not help.

Link to comment
Share on other sites

on that line 80 here's what I've got on my site:

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

 

what do you have on the section found about line 314?

Link to comment
Share on other sites

on that line 80 here's what I've got on my site:

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

 

what do you have on the section found about line 314?

 

Below is my code from 315 to 341.

From the cap mod there are some alterations from the clean OSC around 820

along with the stripslashes taken out at line 550 and 585.

 

// copy image only if modified

$cid = explode('_', $cPath);

foreach($cid as $key => $value){

$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $value . "' && language_id = '1'");

$cat = tep_db_fetch_array($cdat);

$categoryfile .= $cat[categories_name] . "/";

$_SESSION['categoryfile'] = $categoryfile;

}

 

$products_image = new upload('products_image');

$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);

if ($products_image->parse() && $products_image->save()) {

$products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;

} else {

$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');

}

break;

}

}

 

// check if the catalog image directory exists

if (is_dir(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) {

if (!is_writeable(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');

} else {

$messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');

unset($_SESSION['categoryfile']);

}

Link to comment
Share on other sites

try changing this:

// check if the catalog image directory exists
 if (is_dir(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 } else {
$messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
unset($_SESSION['categoryfile']);
 }

 

to this:

// check if the catalog image directory exists
 if (is_dir(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 } else {
$messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
unset($_SESSION['categoryfile']);
 }

It may not solve your problem though... but the bits I've taken out are empty variables that aren't needed.

Link to comment
Share on other sites

Thanks for making this contribution. Just what I was looking for.

 

I have made all the mods except for the admin/categories.php. I have added the ultrapics contrib which has modified all the section that need changing for this one. If someone could work out how to add the necessary code I would be very appreciative.

 

Here is my code.

 

about line 80:

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

 

about line 314:

// copy image only if modified
  if (($HTTP_POST_VARS['unlink_image'] == 'yes') or ($HTTP_POST_VARS['delete_image'] == 'yes')) {
	$products_image = '';
	$products_image_name = '';
	} else {
	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {

 

about line 325:

this one is ok

 

Thank you,

 

Lyle

Link to comment
Share on other sites

I have made all the mods except for the admin/categories.php. I have added the ultrapics contrib which has modified all the section that need changing for this one. If someone could work out how to add the necessary code I would be very appreciative.

Hi there,

Line 80 should be fine if you change this:

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

to this:

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

I believe the code you've got does a similar thing to the first two lines of the replacement code.

 

line 314. The other contrib seems to have added an if statement before the code you need to modify.

just ignore this part:

// copy image only if modified
  if (($HTTP_POST_VARS['unlink_image'] == 'yes') or ($HTTP_POST_VARS['delete_image'] == 'yes')) {
	$products_image = '';
	$products_image_name = '';
	} else {

and edit the part noted in the mod which is directly below the above code:

this:

		$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {

to be replaced with this:

$cid = explode('_', $cPath);
foreach($cid as $key => $value){
$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $value . "' && language_id = '1'");
$cat = tep_db_fetch_array($cdat);
$categoryfile .= $cat[categories_name] . "/";
}
$_SESSION['categoryfile'] = $categoryfile;

	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;
	} else {

 

I hope all works for you :thumbsup:

Link to comment
Share on other sites

I finally got a chance to test our the changes but the images don't show up. In the admin section I get an error message that says: Error: Catalog products images directory does not exist: /Applications/MAMP/htdocs/catalog/images/products/

 

What have I done wrong? I have moved my pictures into subfolders under the images folder eg images/Turkey/Istanbul. I then put the photos into that folder. Do I need to make a folder for the product name?

 

Thanks in advance for your help,

 

Lyle

Link to comment
Share on other sites

I finally got a chance to test our the changes but the images don't show up. In the admin section I get an error message that says: Error: Catalog products images directory does not exist: /Applications/MAMP/htdocs/catalog/images/products/

 

What have I done wrong? I have moved my pictures into subfolders under the images folder eg images/Turkey/Istanbul. I then put the photos into that folder. Do I need to make a folder for the product name?

 

Thanks in advance for your help,

 

Lyle

Hi, sorry for taking so long to get back to you.

 

in admin/categories.php,

find this code I gave you (about line 80):

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

and replace with this:

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

 

please note that I haven't tested that code, but hopefully it should work.

Someone else is having a similar problem, both of you had the same code starting at line 80. I'm hoping that this will fix it for you both.

Please let me know whether it does or not!

Link to comment
Share on other sites

Thanks for your help. Unfortunately no joy. I still get the same error. Can you confirm how I am supposed to set up my image folder. In the images folder I have put folders with the category titles. Inside these folders are the sub-category folders. Inside thes are the product images. I have done this for existing products and have also done this for a new product as well. Am I doing this right?

 

Thank you again for your help.

 

Lyle

 

BTW I may not be able to check this for a little while as we are expecting our second child any time now.

Link to comment
Share on other sites

  • 3 weeks later...

Hi, I've istalled the mod, which is perfect for me because I'll have many categories, subcategories and products to display and want to keep them organized. I'm having the following problem and can't seem to find the answer in any of these post so far:

 

I can get Category and Subcategory images posted without a problem, but I get the seemingly ubiquitous

 

" Error: Destination does not exist.

Error: Catalog products images directory does not exist: /home/humidors/public_html/catalog/images/products/"

 

when I try to add images to a product. I've checked and re-checked my work and can't find anything at all wrong. I'm using the latest install of osC 2.2rc1 (mid-July I think) and v 1.4 of your mod.

 

One thing I did notice, the last bit of code to be replaced in catalog/admin/categories.php may be an issue. Even with a fresh copy of the file when I search for the code to be replaced it's not found, and since it's supposed to be included in v 1.4 already I searched for that too just for good measure. What looks to be the same, but is somehow different. This is what I find starting on line 316:

 

// copy image only if modified
$cid = explode('_', $cPath);
foreach($cid as $key => $value){
$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $value . "' && language_id = '1'");
$cat = tep_db_fetch_array($cdat);
$categoryfile .= $cat[categories_name] . "/";
$_SESSION['categoryfile'] = $categoryfile;
}

       $products_image = new upload('products_image');
       $products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
       if ($products_image->parse() && $products_image->save()) {
         $products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;
       } else {
         $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
       }
       break;
   }
 }

 

Am I missing something?

 

Thanks!

Link to comment
Share on other sites

I may have a different take on the same "missing directory" problem.

 

On Previewing a new product, I also get:

 

Error Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: C:/webserver/VertrigoServ/www/oscommerce/catalog/images/products/plants/

 

However, if I push Ctrl+5 on the preview page, I then get:

 

Success: File upload saved successfully.

 

And it all works perfectly! I can't of course tell the upload person to push ctrl+F5 each time, but perhaps someone who understands coding can now identify the problem!

Link to comment
Share on other sites

  • 2 weeks later...

hey guys!

sorry for being non-existent for the last month.... I've been having a really hectic time and then had to go away for a bit.

sorry.

 

I've just spent quite a while fiddling with the code and reworking parts of it.. Although I've come to the conclusion that the problem isn'e completly due to the code.. although it is partly :P

Below I've included the code that I'm using, which works fine.. It's a slightly modified version of the one in the download (Which I'm about to update too).

I think the problem you're all recieving is due to the use of the category drop-down selection in the top right. When you use that to select categories instead of clicking on the folders, it doesn't cary the parent categories with it, so the image filename tries to save it to an incorrect directory.

I'll see if I can work on that for another release though.

 

In the meantime, just click on thye category folders instead of using the drop-down, thanks.

 

 

below is the exact same code that I am currently using on my own shop, which isn't live yet, but you can take a look here: www.shop.gimppro.co.uk and see that the sub category products have images in their own category folder (right-click on the product image and go to properties).

 

in admin/categories (about line 315):

// copy image only if modified
unset($_SESSION['categoryfile']);
$cid = explode('_', $cPath);
$categoryfile = '';
foreach($cid as $key => $value){
if($value != '0'){
	$cdat = tep_db_query("SELECT `categories_name` FROM `categories_description` WHERE `categories_id` = '" . $value . "' && `language_id` = '1'");
	$cat = tep_db_fetch_array($cdat);
	$categoryfile .= $cat['categories_name'] . "/";
}
}
$_SESSION['categoryfile'] = $categoryfile;

	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}
	break;
}
 }

// check if the catalog image directory exists
 if (is_dir(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile)) $messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 } else {
$messageStack->add(ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
unset($_SESSION['categoryfile']);
 }
?>

that code is the whole two blocks of code in the tutorial together, but goes down a little furthur to the '?>' line. As they link together with no other code in-between I've just put them in one section here for you.

That's what I'm using and it works fine and I'm using osc 2.2 which I believe is the latest release.

 

 

I hope this all works fine! let me know if you still get problems.

I've also set up a second help topic on my own forum here: http://www.forum.gimppro.co.uk/viewtopic.php?t=43

Which I'll happilly answer questions on.

Link to comment
Share on other sites

Also I am having a problem with the products to error that comes up for the products is

Error Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: ..//catalog/images/products/

^

note this destination is there but it is not working

 

also then a product does work it does not upload in the normal product/... folder it wants to load like this barrels__barrel_accessories/barrels/autococker/Ceramic_1.gif not in the products folder.....

 

and for the Manufacturers thing there is no errors, it uploads the image but then when it comes back to the normal info to shows you the image, its not there...

 

so i guess it real doesn't upload it...

 

I dont know whats up I know I installed it right I followed the steps...

 

I installed the 1.4v

Link to comment
Share on other sites

OK I will try to give as much details as I can for my to problem:

 

1. Manufacturers image problem

when I go to edit a manufacturers image and use the browse and get my image I want and click down it reload the hold window and nothing happen, no errors, no image was ever upload becuase it comes up and says this....

mwindowrj2.gif

and I did make the manufacturers folder for the images

 

 

2. Product image problem

Ok, when I upload product, no image is uploaded, two error come up, and the product image file trail is not right is says "S2_1.gif"

Error Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: ..//catalog/images/products/

^

note this destination is there

Link to comment
Share on other sites

1. Manufacturers image problem

when I go to edit a manufacturers image and use the browse and get my image I want and click down it reload the hold window and nothing happen, no errors, no image was ever upload

 

and I did make the manufacturers folder for the images

could you show me the code in catalog/admin/includes/configure.php, on the line containing this:

define('DIR_FS_MANUFACTURERS_IMAGES',

and the code you have in catalog/admin/manufacturers.php at about line 41. It should be this:

		$manufacturers_image = new upload('manufacturers_image');
	$manufacturers_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_MANUFACTURERS_IMAGES);
	if ($manufacturers_image->parse() && $manufacturers_image->save()) {
	  tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . DIR_FS_MANUFACTURERS_IMAGES . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'");
	}

 

 

2. Product image problem

Ok, when I upload product, no image is uploaded, two error come up, and the product image file trail is not right is says "S2_1.gif"

Error Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: ..//catalog/images/products/

I think the second problem has been fixed with a post of mine in this topic. You can find it here: http://www.oscommerce.com/forums/index.php?s=&...t&p=1118044

No-one's verified if this fix works or not though so let me know!

Link to comment
Share on other sites

ok the manufacturers image work now but the product image still dont work

 

and I tried that one thing that you put to fix it but it did not work for me.

 

I tried creating a new product and it haves still two errors

 

Error Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: ..//catalog/images/products/

 

and I have created the "products" folder so I dont understand that error

pthingfi9.jpg

thats what it looks like after uploading a image to the product

Edited by JS_Supplies
Link to comment
Share on other sites

ok the manufacturers image work now but the product image still dont work

 

and I tried that one thing that you put to fix it but it did not work for me.

 

I tried creating a new product and it haves still two errors

 

Error Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: ..//catalog/images/products/

 

and I have created the "products" folder so I dont understand that error

 

okay.. what've you got in admin/includes/configure.php on the line that starts:

  define('DIR_FS_CATALOG',

Link to comment
Share on other sites

what on

  define('DIR_FS_DOCUMENT_ROOT'

and

  define('DIR_WS_CATALOG'

I'm only asking because I don't understand why the error message says the directory as: ..//catalog/images/products/

it shouldn't be using ../ and their should be something between the two slashes '/'.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...