because dropzone sends images one by one.
Please read the following note if you want all the files at once;
https://docs.dropzone.dev/configuration/tutorials/combine-form-data-with-files
am uploading multiple images to the database using Dropzone.js.am able to send the data to the controller in the function, but the images are sent as single images, and am able to upload the single image to the DB perfectly. I want to upload the images in batches using the foreach loop because I want to resize them using image intervention. how can I convert the images into an array?
this is my dropzone form in the view
<form id="dropzone-form" action="{{ url('admin/alternateimages/'.$rentaldata->id) }}" class="dropzone form-horizontal" role="form" method="POST" enctype="multipart/form-data">
@csrf
</form>
this is the dropzone script
Dropzone.autoDiscover = false;
var dzonerentalimages = new Dropzone("#dropzone-form",{
maxFilesize: 2,
maxFiles: 3,
acceptedFiles: ".jpeg,.jpg,.png",
});
dzonerentalimages.on("success",function(file,response){
console.log(response.message)
if(response.success == 1)
{
alertify.set('notifier','position', 'top-right');
alertify.success(response.message);
alternateimagestable.ajax.reload();
}
});
this is the function in the controller
public function alternateimages(Request $request,$id)
{
$rentaldata=Rental_house::with('rentalalternateimages')->select('id','rental_name','location_id','rental_image')->find($id);
$data = array();
$validator=Validator::make($request->all(),
[
'file'=>'required|mimes:png,jpg,jpeg|max:2048'
]);
if($validator->fails()){
$data['success']=0;
$data['error']=$validator->errors()->first('file');
}else{
$images=$request->file('file');
dd($images);die();
on dd($images);die(); am getting data for an image as single but I want to get the images an array so that i can upload it using foreach loop
because dropzone sends images one by one.
Please read the following note if you want all the files at once;
https://docs.dropzone.dev/configuration/tutorials/combine-form-data-with-files
Please or to participate in this conversation.