Jump to content
Sign in to follow this  
Dragen

Official Topic For 'change Default Image Directories' Contrib

Recommended Posts

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 '/'.

  define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT); // where your pages are located on the server. if $DOCUMENT_ROOT doesnt suit you, replace with your local path. (eg, /usr/local/apache/htdocs)

  define('DIR_WS_CATALOG', '/catalog/');

Share this post


Link to post
Share on other sites

when i do that it makes the little English flag goes a way and it still don't work... same errors

 

Error: Destination does not exist.

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

Share this post


Link to post
Share on other sites

okay..

are you sure you copied the code properly in my fix?

// 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']);
 }
?>

and are you using the drop-down menu to select the categories (shown below)?

drop-downcategories.gif

If you are then that will cause an error.

you need to select categories by clicking on it in the main list instead

Share this post


Link to post
Share on other sites

ya, still don't work and I don't use the drop down menu, personal I think its a pain using it and never use it

untitledia7.jpg

Share this post


Link to post
Share on other sites
ya, still don't work and I don't use the drop down menu, personal I think its a pain using it and never use it

I checked through all your code and it looks fine. I'm pulling at straws here but try changing the code to this:

<?php
// 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_WS_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_WS_CATALOG . 'images/' .  . DIR_FS_PRODUCTS_IMAGES . $categoryfile)) {
if (!is_writeable('..' . DIR_WS_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']);
 }
?>

 

also to get the correct error message if it doesn't work open admin/includes/languages/categories.php:

find the line starting:

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST',

replace with:

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Error: Catalog products images directory does not exist: ' . '..' . DIR_WS_CATALOG . 'images/' .  . DIR_FS_PRODUCTS_IMAGES . $_SESSION['categoryfile']);

Edited by Dragen

Share this post


Link to post
Share on other sites

when i replace the code the whole oscommerce goes blank.... man I feel bad I am making work so hard on this.... I wish I could understand this code then I could help

Edited by JS_Supplies

Share this post


Link to post
Share on other sites

ok, is there a way to just make the manufacturers and categories just change directories and the products not since the products don't like to corporate, unless you want to still figure out how to make then work its up do you..

Share this post


Link to post
Share on other sites

hm... I'm not sure what the problem is.

If you have the code in admin/categories.php how it is in my original fix that I linked you to.. (before I changed it in my last post)

and the same with admin/includes/languages/categories.php..

change this prt back:

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST',

basically undoing what my last post told you to do.

 

Then when you go to upload a product and press submit. When it shows the error message, refresh the page (f5). Sometimes the error message lags, so it may say something different (although I doubt it..)

 

then copy out the exact error message.. for me.

Share this post


Link to post
Share on other sites

admin/categories.php (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']);
 }

admin/includes/languages/categories.php (line 96)

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Error: Catalog products images directory does not exist: ' . DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $_SESSION['categoryfile']);

Is this right?

Share this post


Link to post
Share on other sites

Yeah, that looks right to me.

When you upload a new product and it gives you the error, instead of going back and trying again, refresh the page (press f5).

Then what is the exact error message you recieve?

If you let me know the exact directory it can't find, after the page refresh.

Share this post


Link to post
Share on other sites
Yeah, that looks right to me.

When you upload a new product and it gives you the error, instead of going back and trying again, refresh the page (press f5).

Then what is the exact error message you recieve?

If you let me know the exact directory it can't find, after the page refresh.

Before inserting image:

justincatalogwr8.png

 

Before Refreshing:

beforerecd7.jpg

 

After Refreshing:

afterrevv2.jpg

 

After Inserting image:

afterinsertingop1.jpg

Share this post


Link to post
Share on other sites

admin/includes/configure.php ( line 37)

//sets default image directories
 define('DIR_FS_MANUFACTURERS_IMAGES', 'manufacturers/');
 define('DIR_FS_CATEGORIES_IMAGES', 'categories/');
 define('DIR_FS_PRODUCTS_IMAGES', 'products/');
//

 

admin/includes/languages/english/categories.php (line 96)

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Error: Catalog products images directory does not exist: ' . DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $_SESSION['categoryfile']);

 

admin/categories.php (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 . "'");
	}

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

Share this post


Link to post
Share on other sites

Thanks.

From looking at your code I really can't see what's causing the problem. For some reason it seems to be looking in

..//catalog/images/products/

to save the image, but the directory is invalid. You can have ..//

I'd have expected the directory to be something like this:

/home/fhlinux181/s/catalog/images/products/

 

I tried changing the directory it was looking in for you, but it didn't seem to work.

I'm sorry, but I can't seem to figure this one out.

 

I'm gonna try one last thing in admin/includes/configure.php what've you got for:

define('DIR_FS_CATALOG_IMAGES',

Share this post


Link to post
Share on other sites
Thanks.

From looking at your code I really can't see what's causing the problem. For some reason it seems to be looking in

..//catalog/images/products/

to save the image, but the directory is invalid. You can have ..//

I'd have expected the directory to be something like this:

/home/fhlinux181/s/catalog/images/products/

 

I tried changing the directory it was looking in for you, but it didn't seem to work.

I'm sorry, but I can't seem to figure this one out.

 

I'm gonna try one last thing in admin/includes/configure.php what've you got for:

define('DIR_FS_CATALOG_IMAGES',

  define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');

Share this post


Link to post
Share on other sites

hey I fix the double //

 

it was here:

admin/includes/local/configure.php (line 4)

  define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT . '../');

take out the "/" and the error reads:

11tm5.jpg

Share this post


Link to post
Share on other sites

define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT . '...');

13sc8.jpg

define('DIR_FS_DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']);

12pl7.jpg

Share this post


Link to post
Share on other sites

Hi! Great contrib for better organizing!

 

It works fine, but it saves the images in images/products, not images/products/category/subcategory.

 

I'm using the latest versions of both osc and this contrib, so where am I going wrong? Please, help.

 

Thank you!


My Tiny Contribution - Romanian Buttons

Share this post


Link to post
Share on other sites
Hi! Great contrib for better organizing!

 

It works fine, but it saves the images in images/products, not images/products/category/subcategory.

 

I'm using the latest versions of both osc and this contrib, so where am I going wrong? Please, help.

 

Thank you!

 

What code do you have on admin/categories.php around line 315 through to about line 370?

Share this post


Link to post
Share on other sites

I guess there's the problem, because I also have Ultra Pics installed.

 

And now I have another error: I added a few images and everything was ok, but now I get this: catalog/images/produse/////////////////////////////////Thomas_pod_suspendat_TO7 - a lot of slashes... And it worked before, saving the images in images/products and showing the image with the correct path. Now the path is wong when I try to dd an image and the image doesn't show.

 

And this is the code from admin/categories.php:

 

 

 

case 'new_product_preview':

// copy image only if modified

 

 

 

//BOF UltraPics

if (($HTTP_POST_VARS['unlink_image'] == 'yes') or ($HTTP_POST_VARS['delete_image'] == 'yes')) {

$products_image = '';

$products_image_name = '';

} else {

//EOF UltraPics

 

// Change default folder for images

 

$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;

 

// End Change default folder for images

 

 

} else {

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

}

 

 

//BOF UltraPics

 

 

I really need a solution to this, because I'm supposed to have the shop online tomorrow.... I hope I'll make it! Thank you!

Edited by roxanacaz

My Tiny Contribution - Romanian Buttons

Share this post


Link to post
Share on other sites

It is quite strange over here, since every product I add, the image name gets one more / added to the path.

 

I basically wanted this mod so my /images directory would not get cluttered, and because I already have my product thumbnails stored on another directory. So basically I installed it, used 100x100/ as my DIR_FS_PRODUCTS_IMAGES , and tested it.

 

I actually do not want subdirs for my store categories so I thought maybe I would have to do some changes, but I tried adding an item and the image ended up on /images/100x100/ instead of /images/100x100/category/ (which I hadn't created, so I thought maybe it would give me an error). That was great, since I actually want all images to end up there, no matter what category the product is created in (I thought about just creating the product on the top category, so the image would end on /images/100x100, and then move the product to the desired category).

 

But after adding some more test products, for some weird reason with every new product the image name that gets added to the databse is growing as follows:

 

100x100//a.jpg

100x100///b.jpg

100x100////c.jpg

...

100x100///////aaa.jpg

 

Every new product I add/every new image I upload, the name will have one more / on the name.

 

I am quite sure my problem is on the following lines of /admin/categories.php , but my PHP knowledge is not even close to letting me even understand this code (this are the changes done about line 314 on v1.4):

 

// 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;
   }
 }

 

Any hints on how to fix this would be greatly appreciated (I would me more than fine removing the part that adds the category subdirs, since I do not want to use them, I want all images stored on /images/100x100)

 

Thanks!


MindTwist of Twisted Reality and Twisted Tienda

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  

×