Jump to content
Sign in to follow this  
Dragen

Official Topic For 'change Default Image Directories' Contrib

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

}

 

:'(

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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?

Share this post


Link to post
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']);

}

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

thanks lee for your speedy reply :D have made the changes am to tired to check if it is all working. maybe tomorrow night!

 

lyle

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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://forums.oscommerce.com/index.php?s=&...t&p=1118044

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

Share this post


Link to post
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

Share this post


Link to post
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',

Share this post


Link to post
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 '/'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×