Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Set chmod of folders automatically in assets/Uploads


Go to End


2 Posts   854 Views

Avatar
Bereusei

Community Member, 96 Posts

29 October 2013 at 11:59pm

Hey guys,

I´m using this code...

$CategoryTitle = $this->Categories()->First()->Title;
$CategoryTitle = preg_replace('/[^A-Za-z0-9]+/','-',$CategoryTitle);
$CategoryTitle = preg_replace('/-+/','-',$CategoryTitle);
$uploadField->setFolderName('Uploads/Products/' . $CategoryTitle);

...to create folders with the name of current category, so I automatically get a nice organized structure.

The problem is that the folders, that the system created, gets chmod 755 and I get a permission-denied-error.
To fix this, I must set chmod from the folder and all other folders & files in this folder to 777 by hand.

Any idea where php-function "mkdir" sit to manage chmod or are there any other suggestions to set permission from all things in the Upload-directory to 777 automatically?

Avatar
Nivanka

Community Member, 400 Posts

3 November 2013 at 2:53am

why dont you try giving making the chown to the webserver user (_www) ? i think thats will be better rather than making assets folder 777