如何将laravel 5.3中的存储路径更改为public?

Mil*_*ike 11 laravel laravel-5 laravel-5.3

laravel 5.3,如果我从表单上传文件,它将存储在自己的存储目录中.然后我应该symlink在公共路径中创建一个到该存储路径.

由于限制,我不能在我的系统上使用创建符号链接.如何直接上传文件public/uploads而不是storage/app/uploads

我试图设置路径,AppServiceProvider.php但它不起作用.

public function register()
{
    //not working:
    $this->app->useStoragePath( $this->app->basePath() .  "/upload");

    //also not working:
    // $this->app->bind('path.storage', function () {
    // return $this->app->basePath() . '/upload';
    // });

}
Run Code Online (Sandbox Code Playgroud)

通过"不工作"我的意思是它仍然上传到默认存储目录.我也清除了缓存.

这是上传部分(在控制器中使用):

        $request->image->storeAs("uploads", "uploaded_image.jpg");
Run Code Online (Sandbox Code Playgroud)

谢谢你的任何提示.:)

Geo*_*rna 21

在Laravel 5中你现在必须这样做config/filesystems.php.您可以像这样添加新磁盘:

'disks' => [

    'uploads' => [
          'driver' => 'local',
          'root'   => public_path(), // previously storage_path();
    ],

]
Run Code Online (Sandbox Code Playgroud)

然后执行以下操作以使用它:

Storage::disk('uploads')->put('filename', $file_content);
Run Code Online (Sandbox Code Playgroud)