I am using angular 7 with laravel for backend.I am having one form where i have one dropdown with list of companies. User will select particular company onchange company i am displaying one html table with list of employees of particular company.
Code of html table :
<table *ngIf="allemp" >
<tr>
<th>ID</th>
<th>Name of Employee</th>
<th>Attached Payslip</th>
</tr>
<tr *ngFor="let data1 of allemp">
<td></td>
<td></td>
<td><input type="file" (change)="onFileChangeInfo($event)" multiple></td>
</tr>
</table>
As you can see in last td
i am having input type file from where i want to add each employees of different salary slips into database.
My function in ts file to get multiple files:
onFileChangeInfo(event) {
console.log(event);
const reader = new FileReader();
if(event.target.files && event.target.files.length > 0) {
const [file] = event.target.files;
reader.readAsDataURL(file);
console.log(file);
reader.onload = () => {
this.myForm1.patchValue({
'inv_blob': reader.result,
'inv_pdf':file.name,
});
this.cd.markForCheck();
};
}
}
On console.log(file)
i am able to get each files. but in backend api only goes last file.
I am not able to get all files that i am getting into console.log(file) in my backend.
$blob_payslip = $request->inv_blob;
$filename_contract =$request->inv_pdf;
$paySlipUpload = CapsMaster::UploadFile1($blob_payslip,$this->payslipfolder,'abc',$filename_contract);
$payslip_data->inv_pdf='payslips/'.$billing_com.'/'.$paySlipUpload;
I tried with foreach loop but its not working for me.I want to store different rows for each selected file into database. please help me with the same.send me some links if possible for same. because i google for this issue but not getting proper answers.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire