I try the following method to create a folder with it's subdirectorys if it does not already exists:
public function createFolderIfNotExist($path){
//Check if the folder already exists
if(!File::Exists($path)){
//make folder with $path generate recursive with right 0775
File::makeDirectory($path, 0775 , true);
}
}
When running localy it works fine (xampp), when pushed to the server it returns
permission denied
First lines of the error
in Filesystem.php line 337
at HandleExceptions->handleError('2', 'mkdir(): Permission denied', '/var/www/****/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', '337', array('path' => '/var/www/****/public/images\product\206', 'mode' => '509', 'recursive' => true, 'force' => false))
at mkdir('/var/www/****/public/images\product\206', '509', true) in Filesystem.php line 337
at Filesystem->makeDirectory('/var/www/****/public/images\product\206', '509', true) in Facade.php line 216
at Facade::__callStatic('makeDirectory', array('/var/www/****/public/images\product\206', '509', true)) in ProductController.php line 452
The error message makes it look like im trying to set the permissions to 509
The path that I pass is:
$pathThumb = public_path('images\product\\'.$product->id.'\thumb');
When checking the permisson on the server it says 775 for the public folder.
What am I doing wrong?
The unix user that the php server runs under does not have permission to access the parent directory at $path
.
Googling "permission denied" makeDirectory
shows the same.
The problem is outside of PHP, so you need to determine how to make the folder writeable like this, or make the files in a directory that is writable to the php server process user. This should involve your sysadmin/devops person.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments