我只是添加添加更多图像,当用户单击添加更多按钮时,我将添加输入及其字段名称,例如照片[]
当我仅使用照片时,我正在使用Ajax来添加数据,
<div class="col-md-6">
<div class="form-group">
<label class="f-14 f-w-700">Product Photo</label>
<input type="file" class="form-control" name="photo[]">
<small class="text-danger f-w-700 photo-error-label"></small>
</div>
</div>
$validate = Validator::make($request->all(),[
'category_id'=>'required',
'sub_category_id'=>'required',
'product_id'=>'required',
'name'=>'required',
'keyword'=>'required',
'description'=>'required',
'specification'=>'required',
'model_no'=>'required',
'document'=>'required',
'photo.*'=>'required',
'video.*'=>'required',
],[
'category_id.required'=>'The category field is required.',
'sub_category_id.required'=>'The sub category field is required.',
'product_id.required'=>'The product field is required.'
]);
/* if fail validation then return error in json with status code */
if($validate->fails()){
return response()->json(["errors"=>$validate->errors()],422);
}