【问题标题】:chmod(): Operation not permitted when upload file with laravel 6chmod():使用 laravel 6 上传文件时不允许操作
【发布时间】:2020-03-03 21:28:35
【问题描述】:

我正在使用file system storage 上传文件。当我将 filesystem_driver 从本地更改为公共时,我收到此错误:

供应商/联盟/flysystem/src/Adapter/Local.php:367

public function setVisibility($path, $visibility){
    $location = $this->applyPathPrefix($path);
    $type = is_dir($location) ? 'dir' : 'file';
    $success = chmod($location, $this->permissionMap[$type][$visibility]); // line 367

    if ($success === false) {
        return false;
    }

磁盘设置

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
        'permissions' => [
            'file' => [
                'public' => 0664,
                'private' => 0600,
            ],
            'dir' => [
                'public' => 0775,
                'private' => 0700,
            ],
        ],
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
    ],

],

我试图根据这个post更改文件权限,但它不起作用。如果我将filesystem_driver 更改为本地,我将无法在前端显示图片。这是一个本地开发环境 WSL Ubuntu 18

我在这里做错了什么?

【问题讨论】:

  • 存储目录有错误的权限,它应该是apache或nginx作为目录的所有者,通过sudo chown www-data:www-data storage
  • @Bader 我这样做了,但没有帮助。文件正在上传,但无论发布表单后都会出现此错误。
  • 您是否将您的公用文件夹与php artisan storage:link 关联
  • @bader 如果您的 web 文件在 linux 之外,那么 Windows 子系统 linux 不支持 cmod。我将文件移动到 linux 文件系统中,它现在可以工作了。我唯一的问题是我现在无法显示图片。

标签: php laravel file


【解决方案1】:

问题是 ntfs 文件系统 https://github.com/Microsoft/WSL/issues/81 下不支持 cmod

【讨论】:

    猜你喜欢
    • 2019-01-12
    • 2013-11-01
    • 1970-01-01
    • 2020-01-31
    • 2018-02-15
    • 2021-11-04
    • 2017-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多