jeudi 25 janvier 2018

Laravel Upload Image to img folder

Whats the best way for me to upload an image or more with form class to my Storage?

Blade:

<form class="" action="" method="post">
<div class="form-group">
        <div class="form-group">
          <label for="myimage">  <img src="/img/" height="80" width="80"></label>
          <input type="file" id="myimage" name="myimage"></font>

        </div>

      </div>

Controller:

   public function NewProduct(Request $request){
      $user = Auth::user();
      $user->myimage= date('mdYHis') . uniqid() . $request->myimage;
      $user->save();
      return redirect()->back();
    }

Here in my Controller it saves only the random generated name in the DB, but dont upload the file to my Server. I want use this path for saving path:

/public/img/

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire