How to get file URL using Storage facade in laravel 5?

前端 未结 13 803
庸人自扰
庸人自扰 2020-11-30 22:40

I\'ve been experimenting using the new Flysystem integration with Laravel 5. I am storing \'localised\' paths to the DB, and getting the Storage facade to complete the path

13条回答
  •  臣服心动
    2020-11-30 23:21

    If you just want to display storage (disk) path use this:

    Storage::disk('local')->url('screenshots/1.jpg'); // storage/screenshots/1.jpg
    Storage::disk('local')->url(''): // storage
    

    Also, if you are interested, I created a package (https://github.com/fsasvari/laravel-uploadify) just for Laravel so you can use all those fields on Eloquent model fields:

    $car = Car::first();
    
    $car->upload_cover_image->url();
    $car->upload_cover_image->name();
    $car->upload_cover_image->basename();
    $car->upload_cover_image->extension();
    $car->upload_cover_image->filesize();
    

提交回复
热议问题