i am using dynamic add files and others input fields using jquery, in html using array as name and in route using POST method
when click on add button dynamically add html tags and user will add files and input field and submit
i was upload 5 files and other 5 input fields but when print that files in controller only display 3 files index but display 5 input fields , 2 upload files are missing
View
<form action="{{ route('admin.order.multipleorderstore') }}" method="post" enctype="multipart/form-data" id="ordersubmitbtn">
<div class="form-group col-md-4 col-xs-12 directtocust'+i+'" style="display:none">
<label>Company Name</label>
<input type="text" placeholder="Enter Company Name" class="form-control" id="com_name'+i+'" name="com_name[]"/>
</div>
<div class="form-group col-md-4 col-xs-12">
<label for="invoice">Invoice</label>
<span class="text-danger">*</span>
<input type="file" class="form-control invoicecls" name="invoice[]" required/>
</div>
</form>
Route
Route::post('order/multipleorderstore', 'OrderController@admin_multipleorderstore')->name('admin.order.multipleorderstore');
Controller
public function admin_multipleorderstore(Request $request)
{
//if ($request->method() == 'POST') {
$data = $request->all();
echo '<pre>';
print_r($data);
print_r($request->file('invoice'));
exit;
}
Output
[com_name] => Array
(
[0] => 27
[1] => 27
[2] => 27
[3] => 27
[4] => 31
[5] => 30
)
[invoice] => Array
(
[0] => Illuminate\Http\UploadedFile Object
(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 55.6 KB .pdf
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => application/pdf
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[hashName:protected] =>
[pathName:SplFileInfo:private] => /tmp/phpT5cqp5
[fileName:SplFileInfo:private] => phpT5cqp5
)
[1] => Illuminate\Http\UploadedFile Object
(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 55.6 KB .pdf
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => application/pdf
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[hashName:protected] =>
[pathName:SplFileInfo:private] => /tmp/phpy9u01S
[fileName:SplFileInfo:private] => phpy9u01S
)
[2] => Illuminate\Http\UploadedFile Object
(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 55.6 KB .pdf
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => application/pdf
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[hashName:protected] =>
[pathName:SplFileInfo:private] => /tmp/phpePaNQG
[fileName:SplFileInfo:private] => phpePaNQG
)
)
please help