Jump to content
Latest News: (loading..)
Sign in to follow this  
Dragen

Official Topic For 'change Default Image Directories' Contrib

Recommended Posts

Ok, so answering my own post, the line to comment out for me was the following:

 

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

 

Strange, since before doing that I had commented out the whole "foreach" loop and that wasn't working for me. I will just let the loop in there adding a few unneeded queries to the DB, no big deal since they will only happen when I add a new product.


MindTwist of Twisted Reality and Twisted Tienda

Share this post


Link to post
Share on other sites

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

hi mindtwist. If you're not wanting seperate category/sub-category files justs change the code you had above to this:

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

That should do the trick.

 

roxanacaz I'm not sure what you're error is...

Try changing this part:

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

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

It might solve the problem...

Share this post


Link to post
Share on other sites

Dragen,

 

Thanks a lot for your answer. I did think at first too that removing that part would work, but it seems it didn't for me.

It could be very wall that I was doing something else wrong on my side (uploading the wrong file, to the wrong dir, modifying the wrong file... who knows) since later just commenting out that line worked, so I didn't touch it any more.

 

Thx!


MindTwist of Twisted Reality and Twisted Tienda

Share this post


Link to post
Share on other sites
Dragen,

 

Thanks a lot for your answer. I did think at first too that removing that part would work, but it seems it didn't for me.

It could be very wall that I was doing something else wrong on my side (uploading the wrong file, to the wrong dir, modifying the wrong file... who knows) since later just commenting out that line worked, so I didn't touch it any more.

 

Thx!

hmm.. It might also have been because you hadn't removed a couple of other bits of code that my suggestion made, but if it's working anyway that's good! :thumbsup:

Share this post


Link to post
Share on other sites

One more quick question... I am not 100% sure but I think that before installing this mod my product/category images were not being uploaded with permissions 777 like they are now, is that possible? Might it be a security threat to have them with 777, or they are supposed to be that way?

Thx!


MindTwist of Twisted Reality and Twisted Tienda

Share this post


Link to post
Share on other sites
One more quick question... I am not 100% sure but I think that before installing this mod my product/category images were not being uploaded with permissions 777 like they are now, is that possible? Might it be a security threat to have them with 777, or they are supposed to be that way?

Thx!

I think they're always uploaded with 777, but even if they're not meant to be 777 on the images wont matter at all. It's more important on the .php files. They should never have 777!

Share this post


Link to post
Share on other sites
I think they're always uploaded with 777, but even if they're not meant to be 777 on the images wont matter at all. It's more important on the .php files. They should never have 777!

 

Dear Dragen and MindTwist.

The problem of ////////////figure.xxx is when you define language_id = '1' and in your db you dont have language=1 in table language.

Share this post


Link to post
Share on other sites

Hello Dragen,

 

I've installed your contrib and it is an awesome feature that I've been looking for. I have the UltraPic with Product Tab contrib installed on the site. Do you have any instruction on how to modify it in order to work with your contrib? Perhaps there is a categories.php file that has the Ultrapic with product tab contrib that I can merge with? Anyone else can help me would be greatly appreciated!

 

Johnny.

Share this post


Link to post
Share on other sites

Hi, this contribution seems just like what i needed.

Im about to install, just wondering if i tried to move a product or a whole category will the image directory also be moved?

Share this post


Link to post
Share on other sites

Hey,

 

I've added this contribution to my site and my first impression is that it will be a valuable addition. The question I have is this: Is there a way to automatically delete an image from a category if the product is moved, copied, or if the product image is changed?

 

I seem to be getting a build up of images in the folder if I change a products picture. The current image gets imported to the category just fine but the old image stays there as well.

 

Any suggestions?

 

Thanks

Share this post


Link to post
Share on other sites

This is a great contribution - I have been looking for this for months! Thank you! Anyone have a recommendations as to which contribution would work well with this one to show more than one image? I had ultrapics, but it seems MoPics would work better with this contribution. Any suggestions?

Share this post


Link to post
Share on other sites

Hi, i am new to oscommerce but this is just what i was looking for, however i have the latest version of oscommerce and in admin/categories.php i can't seem to locate the code to replace. Am i looking in the right place or is there something i am missing?

 

Thanks

Share this post


Link to post
Share on other sites

i install this contrib.. but got some error. like..

 

1st the images doesn't go in the SUB folder. they stay in the manufacturer directory.

 

2nd when i go in my admin to add a product... at the top of the page i have this message

 

 

osc-probleme1.jpg

 

i do exactly what you put in your ver 1.4. when i see the problem i read all thread before this one. i see your post of your categories.php. i copy it in mine and same problem.

 

so what' the problem

 

yours

 

sebastien

Share this post


Link to post
Share on other sites

I've been applying this contribution, and trying to make it work with More Pics 6 (sort of!)

 

BUT I have been having problems when adding *some* product images. After much struggling, I think I've found out why.

 

When you have several levels of sub category, and / or your image has a long filename, this makes a very long string to store in the database (in table products). The field that stores the file structure + file name (products_image) is defined as varchar(64). This is easily filled up with several layers of sub category and a descriptive file names!

 

The field, therefore, is truncated when its written to the database.

 

So when you try to view that product, the image isn't found (because its looking for a file with an incomplete file name.)

 

Sorry - I'm probably not explaining it very well - my brain is a bit fried!!!!

 

But wondered if anyone had any thoughts on this, or if I need to tell my website owner togive her categories & images shorter names!

 

Thanks,

 

Lucy

Share this post


Link to post
Share on other sites

Solution to

'Destination does not exist'

'Error: catalog products images directory does not exist'

 

when trying to upload product images through Admin.

 

Just in case anyone else is searching through these forums looking for help like I was!

 

1. Make sure you create the directory structure on the server with file names *exactly* as they are inyour categories / sub-categories (i.e. with capitol letters, spaces etc)

 

2. Make sure your images /products & images/categories directories all have permissions of 777.

 

ALSO!!! make sure all of your directories below these have permissions of 777

 

So for example, my structure is images/products/Rings/Toe Rings and *each* of these directories must have permissions of 777

 

How this helps someone else - I was struggling for hours with this yesterday and didn't find it spelled out anywhere.

 

Lucy

Share this post


Link to post
Share on other sites

Hello all! I know this topic is quite old but I was hoping that maybe someone was still around working on it? Currently using v2.2 RC2a and have installed the this contrib with the most current bug-fix that eliminated the 'Destination does not exist' and 'Error: catalog product images directory does not exist'.

 

Everything works fine with creating categories and sub-categories under the images/products folder which is exactly what I was looking for......however I have NO images being displayed either in the admin section or the website..just a nice little red X! The image url "says" that it is in the correct directory but it's not there or anywhere else for that matter. Has anyone ran into this issue and perhaps created a fix for it???

 

So far no additional mods have been done to these files other than this contrib. My permissions are set to 755 and I've tried 704 as well.

Any advice would be greatly appreciated or should I switch contribs? If so which on works best with this osc version?

 

Sorry for the rambling and thanks in advance to anyone who can help ( I know you're all busy!)

 

:)

Share this post


Link to post
Share on other sites

if someone uses Ultimate Images Pack by maxidvd

admin categories.php

find each instance

unlink(DIR_FS_CATALOG_IMAGES . $HTTP_POST_VARS['products_previous_image']);

with

unlink(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $HTTP_POST_VARS['products_previous_image']);

and

$products_image_med = new upload('products_image_med');

$products_image_med->set_destination(DIR_FS_CATALOG_IMAGES);

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

$products_image_med_name = $products_image_med->filename;

to look like this for each instance (15 of them)

$products_image_med = new upload('products_image_med');
$products_image_med->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
if ($products_image_med->parse() && $products_image_med->save()) {
$products_image_med_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image_med->filename;

 

hope this helps someone

 

Al

Edited by alman

Share this post


Link to post
Share on other sites

DOES THIS ADDON WORK WITH OS Version 2.3.1 ???

Cannot locate code:

 

 

Also, what files nned to be changed?? - nowhere in your latest download do you indicate where or what pages this code is appied to..... HELP i need this sweet add-on!

 

 

this:

// 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 {

-------------------------------------------------

replace with:

 

// 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);if ($cat[categories_name] == !null){

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

if (file_exists(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile)==false)

{$str = DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile ;

mk_dir($str);

};

$_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 {

 

 

/////////////////////////////////////////////////////////////

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

}

------------------------------------------------

replace with:

 

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

}

function mk_dir($str, $mode=0777) {

if(!(is_dir($str) || @mkdir($str, $mode))) {

mk_dir(dirname($str));

mk_dir($str);

}

}

unset($_SESSION['categoryfile']);

 

 

 

////////////////////////////////////////////////////////

make these changes, then the categories directoires will be aoto build in products directories and products pics will be into their categoies directories. that's easy to manager all products pisc !

thanks,

if have any problem, content me with simomchen41@gmail.com

Share this post


Link to post
Share on other sites

Hi !

I have some problems with function mk_dir.

function mk_dir($str, $mode=0777) {
if(!(is_dir($str) || @mkdir($str, $mode))) {
 mk_dir(dirname($str));
 mk_dir($str);
}

I have a shared environnement. Also PHP MANUAL predict problems with umask.

The code given by PHP MANUAL #6 seems inoperant.

I have manually by FTP renamed/copied/deleted old/renamed/chmoded the new created directory AND similary for transmitted images.

But it's not very cool !

Have you some better function ?

 

Jean

Share this post


Link to post
Share on other sites

For all that are with SAFE_MODE at their server:
You can replace previous function mk_dir by this version:

<?php
function mk_dir($str, $mode=0777) {
  // Check for safe mode
  if( ini_get('safe_mode') ){
      // Do it the safe mode way
      // init connect
      $conn_id = ftp_connect(FTP_SERVER);
      // Identifie with login & password
      $login_result = ftp_login($conn_id, DB_SERVER_USERNAME, FTP_SERVER_PASSWORD);
      if($login_result){
        // Set in root directory
        if (!ftp_chdir($conn_id, "<root_name>")) {
           echo "no success for root setting\n";
        }

        // Create directory $str
        if (ftp_mkdir($conn_id, $str)) {
         echo "Success creating $str\n";
        } else {
         echo "Problem with creating $str\n";
        }
        $command = 'chmod ' . $mode .$str;

        if (ftp_site($conn_id, $command)) {
           echo "Success for $command\n";
        } else {
           echo "Not possible to execute : $command\n";
        }

        // close
        ftp_close($conn_id);
      }else{
        echo 'Bad login or password';
      }
  }else{
      // Do it the regular way
    if(!(is_dir($str) || @mkdir($str, $mode))) {
      mk_dir(dirname($str));
      mk_dir($str);
    }
  }
}
?>

and add in catalog/admin/includes/configure.php

  define('FTP_SERVER', '<your ftp server>');
  define('FTP_SERVER_PASSWORD', '<your ftp password>');

assuming your ftp username is the same as your db username.

 

Jean

Edited by bebe cash 59

Share this post


Link to post
Share on other sites

@@bebe cash 59

 

You have just managed to give help to someone who Posted 27 July 2013 - 09:11

 

Hopefully they would have got help by now. Please try and check the posted date of threads before wasting your time answering questions.


REMEMBER BACKUP, BACKUP AND BACKUP

Before installing the official version of oscommerce first look at a responsive version here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites

:D Hi!

I wrote this for those that have the same problem as me!

 

Please try and check the posted name of threads before wasting your time answering questions. (w00t)

 

all good for you !!

 

Jean

Edited by bebe cash 59

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  

×