
Originally Posted by
gonsman
I am having a permissions problem where the images that I upload are set to 600. If I upload an image under categories/products it works fine. I have seen this issue a few times in this thread, but no real answers. I talked to my host about it and they suggested that I customize the code and manually set the permissions using chmod(). I can easily do this if someone could direct me to the file and line that uploads/moves the files to server. Does anybody know where this is?
I was able to find the answer to this question. The file to edit is /admin/includes/ih_manager.php. In my version, I changed lines 166-212.
Change the following (old code):
Code:
if ($check != 1) {
// check for destination directory and create, if they don't exist!
// Then move uploaded file to its new destination
// default image
if ($_FILES['default_image']['name'] != '') {
io_makeFileDir(DIR_FS_CATALOG_IMAGES.$data['defaultFileName']);
$source_name = $_FILES['default_image']['tmp_name'];
$destination_name = DIR_FS_CATALOG_IMAGES . $data['defaultFileName'];
if ( !move_uploaded_file($source_name, $destination_name) ) {
$messageStack->add( TEXT_MSG_NOUPLOAD_DEFAULT, "error" );
$check = 1;
}
}
// medium image
if ($_FILES['medium_image']['name'] != '') {
$data['mediumImgExtension'] = substr( $_FILES['medium_image']['name'],
strrpos($_FILES['medium_image']['name'], '.'));
$data['mediumFileName'] ='medium/' . $data['imgBaseDir']
. $data['imgBase']
. $data['imgSuffix'] . IMAGE_SUFFIX_MEDIUM
. $data['mediumImgExtension'];
io_makeFileDir(DIR_FS_CATALOG_IMAGES.$data['mediumFileName']);
$source_name = $_FILES['medium_image']['tmp_name'];
$destination_name = DIR_FS_CATALOG_IMAGES . $data['mediumFileName'];
if ( !move_uploaded_file($source_name, $destination_name) ) {
$messageStack->add( TEXT_MSG_NOUPLOAD_MEDIUM, "error" );
$check = 1;
}
}
// large image
if ($_FILES['large_image']['name'] != '') {
$data['largeImgExtension'] = substr( $_FILES['large_image']['name'],
strrpos($_FILES['large_image']['name'], '.'));
$data['largeFileName'] = 'large/' . $data['imgBaseDir']
. $data['imgBase']
. $data['imgSuffix'] . IMAGE_SUFFIX_LARGE
. $data['largeImgExtension'];
io_makeFileDir(DIR_FS_CATALOG_IMAGES.$data['largeFileName']);
$source_name = $_FILES['large_image']['tmp_name'];
$destination_name = DIR_FS_CATALOG_IMAGES . $data['largeFileName'];
if ( !move_uploaded_file($source_name, $destination_name) ) {
$messageStack->add( TEXT_MSG_NOUPLOAD_LARGE, "error" );
$check = 1;
}
}
}
to (new code):
Code:
if ($check != 1) {
// check for destination directory and create, if they don't exist!
// Then move uploaded file to its new destination
// default image
if ($_FILES['default_image']['name'] != '') {
io_makeFileDir(DIR_FS_CATALOG_IMAGES.$data['defaultFileName']);
$source_name = $_FILES['default_image']['tmp_name'];
$destination_name = DIR_FS_CATALOG_IMAGES . $data['defaultFileName'];
if ( !move_uploaded_file($source_name, $destination_name) ) {
$messageStack->add( TEXT_MSG_NOUPLOAD_DEFAULT, "error" );
$check = 1;
}
else
{
chmod($destination_name, 0755);
}
}
// medium image
if ($_FILES['medium_image']['name'] != '') {
$data['mediumImgExtension'] = substr( $_FILES['medium_image']['name'],
strrpos($_FILES['medium_image']['name'], '.'));
$data['mediumFileName'] ='medium/' . $data['imgBaseDir']
. $data['imgBase']
. $data['imgSuffix'] . IMAGE_SUFFIX_MEDIUM
. $data['mediumImgExtension'];
io_makeFileDir(DIR_FS_CATALOG_IMAGES.$data['mediumFileName']);
$source_name = $_FILES['medium_image']['tmp_name'];
$destination_name = DIR_FS_CATALOG_IMAGES . $data['mediumFileName'];
if ( !move_uploaded_file($source_name, $destination_name) ) {
$messageStack->add( TEXT_MSG_NOUPLOAD_MEDIUM, "error" );
$check = 1;
}
else
{
chmod($destination_name, 0755);
}
}
// large image
if ($_FILES['large_image']['name'] != '') {
$data['largeImgExtension'] = substr( $_FILES['large_image']['name'],
strrpos($_FILES['large_image']['name'], '.'));
$data['largeFileName'] = 'large/' . $data['imgBaseDir']
. $data['imgBase']
. $data['imgSuffix'] . IMAGE_SUFFIX_LARGE
. $data['largeImgExtension'];
io_makeFileDir(DIR_FS_CATALOG_IMAGES.$data['largeFileName']);
$source_name = $_FILES['large_image']['tmp_name'];
$destination_name = DIR_FS_CATALOG_IMAGES . $data['largeFileName'];
if ( !move_uploaded_file($source_name, $destination_name) ) {
$messageStack->add( TEXT_MSG_NOUPLOAD_LARGE, "error" );
$check = 1;
}
else
{
chmod($destination_name, 0755);
}
}
}
As you can see, I added 3 chmod functions after each upload. You can change the permissions from 0755 to 0777 or whatever you want. If you want to check the version, the top of this file has the following:
Code:
/**
* ih_manager.php
* manager module for IH2 admin interface
*
* @author Tim Kroeger <[email protected]>
* @copyright Copyright 2005-2006 breakmyzencart.com
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
* @version $Id: ih_manager.php,v 1.2 2006/04/17 18:23:24 tim Exp $
*/
Bookmarks