I am passing three files and few other strings in my post request to the controller. But i don't know the reason why my validation fails.
Here is the form
<form>
<input type="radio" name="inter_fit" id="inter_good_fit" value = "good" >
<input type="radio" name="inter_fit" id="inter_bad_fit" value = "bad">
<input id="report_upload" type="file"/>
<input id="skype_upload" type="file"/>
<input id="audio_upload" type="file"/>
<input type="hidden" id="comp_candidate_id"/>
<input type="hidden" id="comp_profile_id"/>
</form>
var candidate_id = $('#comp_candidate_id').val();
var profile_id = $('#comp_profile_id').val();
var inter_fit = $("input[name=inter_fit]:checked").val();
var report_file = $("#report_upload").prop('files');
var skype_file = $("#skype_upload").prop('files');
var audio_file = $("#audio_upload").prop('files');
var dataString = 'inter_fit=' +inter_fit+ '&report_file=' +report_file+ '&skype_file=' +skype_file+ '&audio_file=' +audio_file+ '&candidate_id=' +candidate_id+ '&profile_id=' +profile_id;
console.log(dataString);
var formData = new FormData();
formData.append("inter_fit",inter_fit);
formData.append("candidate_id",candidate_id);
formData.append("profile_id",profile_id);
var reportInput = $("#report_upload").get(0).files[0];
formData.append("report_file",reportInput);
var skypeInput = $("#skype_upload").get(0).files[0];
formData.append("skype_file",skypeInput);
var audioInput = $("#audio_upload").get(0).files[0];
formData.append("audio_file",audioInput);
$.ajax({
type: "POST",
url: "/complete_interview",
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(data) {
showStatus(data)
},
error : function(xhr ,status ,error)
{
console.log(xhr);
console.log(status);
console.log(error);
}
});
function showStatus(data)
{
console.log(data);
}
When small files like text files are uploaded no problem occurs and it passes the validation. When the large files are uploaded the validation fails. Here is my controller code
public function completeInterview(Request $request){
$val = \Validator::make($request->all(),
['inter_fit' => 'required',
'report_file' => 'required',
'skype_file' => 'required',
'audio_file' => 'required', //not passed
'candidate_id' => 'required',
'profile_id' => 'required',
]);
if ($val->fails()) {
return response()->json(['msg'=>"val_failed"]);
}
}
I have changed the PHP file upload and max post size configuration. I don't understand what is the issue here.
I always get the response as val_failed.