jeudi 24 février 2022

Laravel storage link won't work on production on online server

I have a problem with showing the images that have been uploaded to my Database, but all the data comes normally, but the images do not appear. I think the problem is in the folder from which the images come, knowing that the matter

//php artisan storage:link

works normally on my machine but while uploading the project to an actual server the images don't work Knowing that someone told me to get out all the files that are in the public folder, and put them in the main path

my Codes

///config/filesystems.php

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

//controller sample


    public function add_item(Request $req){
      $req->validate([

        'i_name'=>'required',
        'i_price'=>'required',
        'i_size'=>'required',
        'i_unit'=>'required',
        'i_cat'=>'required',
        'i_short'=>'required',
        'i_full'=>'required',
        'i_photo'=>'required',
        'i_photo1'=>'required',
        'i_photo2'=>'required',
        'i_photo3'=>'required',
        'i_photo4'=>'required',
      ]);
      $i=new item;
     $email=$req->session()->get('supplier');
     $i->supplier=$email;
     $i->name=$req->input('i_name');
      $i->price=$req->input('i_price');
      $i->size=$req->input('i_size');
      $i->unit=$req->input('i_unit');
      $i->category=$req->input('i_cat');
      $i->short_desc=$req->input('i_short');
      $i->full_desc=$req->input('i_full');
      $i->image_url=$req->file('i_photo')->store('items_photo','public'); //fule upload= store
      $i->image1_url=$req->file('i_photo1')->store('items_photo','public'); //fule upload= store
      $i->image2_url=$req->file('i_photo2')->store('items_photo','public'); //fule upload= store
      $i->image3_url=$req->file('i_photo3')->store('items_photo','public'); //fule upload= store
      $i->image4_url=$req->file('i_photo4')->store('items_photo','public'); //fule upload= store
      $i->save(); //insert

      return redirect('s_setting'); 
      }

// from my index view

  <div class="imgs-container">
            <!-- start item div  -->
@if(count($data)>0)
@foreach($data as $d)
            <div class="box">
                <img class="photo" src="" alt="">
                <div class="caption">
                    <h4></h4>
                    <!-- <p></p> -->
                    <p></p>
                    <p></p>
                    {!! Form::open(['url' => 'items/anony']) !!}




{!! Form::close() !!}
                </div>


            </div>
@endforeach
@endif

Any idea



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire