jeudi 25 janvier 2018

Laravel Upload Image and Generate Random ID as name

Whats the best way to generate and random ID number for every image where i want upload in Laravel 5?

My Upload:

<input type="file" id="mypicture" name="mypicture">

Controller:

public function MyPicture(Request $request){
  $user = Auth::user();
  $user->mypicture= $request->mypicture;
  $user->save();
  return redirect()->back();
}

Thats the way i do it always for other things:

->uniqueid = 'VA'.str_random(28);

how can i add it to my Controller for image name? And how can i use only alphabetic character not numbers? Or i must change my DB Table.

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire