php - Managing uploaded files in Laravel - linking public and storage directories -


in laravel 5.1 app, i'm storing images in storage/app/uploads folder.

my local disk:

<?php  'disks' => [      'local' => [         'driver' => 'local',         'root'   => storage_path('app/uploads'),     ],     // other configuration...  ?> 

thing is, can't figure out way use image files after they're uploaded, e.g. source of <img> tag. basically, need retrieve valid path image, can used on page.

for deployment i'm using envoyer provides solution. according envoyer docs:

when storing user uploaded files, you should store them in storage directory of application if using laravel. then, may use "manage linked folders" feature of envoyer create symbolic link public directory storage directory. "manage linked folders" button can found on "deployment hooks" tab of project.

..and clear.

but how "link" storage , public folders in local development environment? laravel provide way it, or need create symbolic link in environment manually?

there few options:

  1. create controller output files

    class assetcontroller {   public function show($id) {     $file = file::findorfail($id);     return response::make(storage::get($file->storage_key), 200, ['content-type' => $file->mime_type]);   } } 
  2. create symlink public/assets => storage/app/

  3. upload files public/assets instead of storage/app

  4. use rewrites on web server serve files storage/app folder - how depends on webserver using. nginx use like

    rewrite ^/v1/assets/(\d+) /../storage/app/$1; 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -