Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

chmod all image files (especially those owned by "nobod


  • You cannot reply to this topic
6 replies to this topic

#1 orchard

  • Community Member
  • 639 posts
  • Real Name:orchard
  • Location:Proprietary

Posted 02 May 2003, 18:46

Several people including me have trouble with uploading and downloading images because they have the wrong permissions and they can't be changed through telnet or FTP because the files belong to user "nobody". To change the permissions of all images that belong to "nobody", create a file named chmodimages.php in the admin directory containing this code
<?php

    require('includes/application_top.php');

    require('includes/configure.php'); 

    $image_query = tep_db_query("select products_image from products"); 

    while ( $info = tep_db_fetch_array($image_query) ) 

    { 

        $target = DIR_FS_CATALOG . DIR_WS_IMAGES . $info['products_image'];

        echo $target . "<br>n"; 

        chmod( $target, 0646 ); 

    }

?>
Then load it into your browser (http://..../admin/chmodimages.php). You should see a list of all your images and the ones that belong to nobody will have their permissions set to 646. You can set the permissions for the ones that belong to you using normal methods in telnet or FTP.

To fix this problem for future uploads, other posts have recommended adding this line
chmod( $target, 0646 );
right after this line
move_uploaded_file($filename['tmp_name'], $target);
in admin/includes/functions/general.php.
In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

#2 carrerarod

  • Community Member
  • 731 posts
  • Real Name:Rodney

Posted 02 May 2003, 21:13

Tried this but errors out looking for the chmod() function.....

#3 orchard

  • Community Member
  • 639 posts
  • Real Name:orchard
  • Location:Proprietary

Posted 02 May 2003, 22:30

What version of PHP are you using? You can find out in the admin in Tools->Server Info. I'm using 4.2.1 (Zend: 1.2.0).
In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

#4 carrerarod

  • Community Member
  • 731 posts
  • Real Name:Rodney

Posted 02 May 2003, 22:37

Quote

What version of PHP are you using? You can find out in the admin in Tools->Server Info. I'm using 4.2.1 (Zend: 1.2.0).

4.3.1 (Zend: 1.3.0)

#5 orchard

  • Community Member
  • 639 posts
  • Real Name:orchard
  • Location:Proprietary

Posted 03 May 2003, 03:02

http://www.php.net/chmod says in the user notes

Quote

This function is very often disabled by the hosting services company.
You might want to ask your hosting company if they have disabled chmod and what you can do as a workaround.
In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

#6 maz

  • Community Member
  • 161 posts
  • Real Name:mazhar

Posted 04 May 2003, 22:44

Hi Paul,

Just a quick thanks. It worked. Well almost. Most of the files were successfully CHMODed and were downloadable. The few that weren't....well I'm trying to figure them out. If I have a problem I may send you the copy of the html result page.

Anyway, thanks again :)

Mazhar.

#7 networkdad

  • Community Member
  • 535 posts
  • Real Name:Jason
  • Location:Battle Ground, WA

Posted 04 May 2003, 23:36

thanks for the tip, very cool! I stopped uploading my images thru admin quite some time ago, as it kept assigning ownership to apache, and not myself.