Hello everyone I am stuck in this. Can anybody please tell me how to save the images in the session in array only. I am using the dropzone library and here I am able to save only one image. I want that if I drop 3 -4 images at a time that my below function is called and in array only 1 index is saved. I want to save all the image in array in session. Any help is appreciated . Please answer The code I am using to save the images in database is here.
public function image_upload(Request $request)
{
$names = [];
$files = $request->file('file');
foreach ($files as $file)
{
echo $names = $file->getClientOriginalName();
}
$image = $request->file('file');
$profileImage = $image->getClientOriginalName();
// Define upload path
$destinationPath = public_path('/uploads/'); // upload path
$extension = $image->getClientOriginalExtension();
$image->move($destinationPath,$profileImage);
$rand_num = rand ( 10000 , 99999 );
$str = $rand_num;
// Saving images In Database
$imagemodel= new ImageDump();
$imagemodel->images=$profileImage;
$imagemodel->rand_img_id = $rand_num;
$request->session()->put('rand_img_id', $rand_num);
$imagemodel->save();
return response()->json(['success'=>$profileImage]);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hGKlBN
via IFTTT
Aucun commentaire:
Enregistrer un commentaire