Jump to content

[Resolved] Creating an image folder with 755 permission (prestashop 1.5.3)


Recommended Posts

I don't have a server problem since I can create an image folder with 755 permission but when I try to upload image and Prestashop have to create a new folder to hold new image folders.It creates it with 644 permission.

 

Anyone can tell me where can I find the code to modify the new folder permission?

Edited by Rymoucha (see edit history)
Link to comment
Share on other sites

Rymoucha,

Is this one time only during installation, or recurring during use of Prestashop? If it's one time during installation, just change it afterwards using chmod -R 755 (with -R being 'recursive')

 

If it is during use of prestashop, please elaborate a little. Where, when etc.

 

pascal

Link to comment
Share on other sites

I made those changes

/**

* default file permissions

* @var int

*/

public $_file_perms = 0777;

/**

* default dir permissions

* @var int

*/

public $_dir_perms = 0777;

/**

* block tag hierarchy

* @var array

*/

and now the folder created has 744 permission unstead of 644

Link to comment
Share on other sites

Looks like you are somehow having limited permission to change 'group' and 'others' permissions.

Maybe on your site there's somehow set a limited permission of 744 max, so trying to change it to 755 will not be possible, as you go beyond the permission you can give/have yourself or so.

 

I read something about it here:

http://php.net/manual/en/function.umask.php

and more here:

https://drupal.org/node/244924

 

In /tools/smarty/sysplugins/smarty_internal_write_file.pgp the umask is temporarily reset to 0

But there are many places in PrestaShop (like /classes/Image.php) that uses mkdir directly, so skipping the smarty file create function and then NOT temporarily resetting the umask to 0.

 

 

Can you try the following?

Open file /classes/Image.php.

 

find public function createImgFolder()

 

N.B. In the comment inside this function you can read that the developers also bumped into problems here with file permissions. They tried to solve it, but apparently isn't working all the time!

 

Try to add the red text for me and see if it works:

 

 

public function createImgFolder()

 

{

if (!$this->id)

return false;

 

if (!file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder()))

{

 

 

$old_umask = umask(0); // set umask to 000 and save old mask in $old_umask

 

 

// Apparently sometimes mkdir cannot set the rights, and sometimes chmod can't. Trying both.

$success = @mkdir(_PS_PROD_IMG_DIR_.$this->getImgFolder(), self::$access_rights, true)

|| @chmod(_PS_PROD_IMG_DIR_.$this->getImgFolder(), self::$access_rights);

 

 

umask($old_umask); // restore old umask value

 

// Create an index.php file in the new folder

if ($success

&& !file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder().'index.php')

&& file_exists($this->source_index))

return @copy($this->source_index, _PS_PROD_IMG_DIR_.$this->getImgFolder().'index.php');

}

return true;

}

 

Didn't try it myself, so please let me know if this helps!

 

pascal

Link to comment
Share on other sites

  • 9 months later...

HI,

 

Thanks for the info.

Just to complete a little:

Some sever doesn't accept CHMOD 0775 for folder so you can specify the parameter   $access_rights   to   0755 (for example)

 

/** @var int access rights of created folders (octal) */
protected static $access_rights = 0755;

Link to comment
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
×
×
  • Create New...