Lara_Love's avatar

upload 3 image

hi / if i need upload 3 image with intervention/image for 3 place profile rule and data

how should change this code ?

 if ($image = $request->file('image')) {
            $destinationPath = 'image/userdata/';
            $profileImage = date('YmdHis') . "." . $image->getClientOriginalExtension();
            $resize = Image::make($image);
            $resize->resize(250, 500);
            $resize->save($destinationPath . $profileImage);
            $input['image'] = $profileImage;
        }

thanks for your help and idea

0 likes
2 replies
vincent15000's avatar

In your input to upload files, you need to set the name as an array.

Then in your controller you have to loop over this variable and for each file in the array you apply the same code as the one you show in your post.

1 like
Sergiu17's avatar

start with html forml

<!-- add multiple attribute, and change image to plural: images -->
<input type='file' name='images' multiple>
if($request->file('images')) {
		foreach($request->file('images') as $image) {
				// resize, name and save each image
		}
}
1 like

Please or to participate in this conversation.