使用角度2应用中的角度材质的文件上载选项

时间:2018-01-22 11:54:33

标签: angular

在这里,我正在尝试创建表单。在一个按钮上,我需要上传一些文件。 但没有得到如何使用角度2材料上传文件。 请任何人建议。

我的代码是,

<table>
<tr>
<p-fileUpload name="myfile[]" url="./upload.php"></p-fileUpload>
</tr>
<tr>
<mat-checkbox>Ignore Errors</mat-checkbox>
</tr>
<tr>
<td>
<button mat-raised-button color="accent">Upload</button>
</td>
<td>
<button mat-raised-button color="accent" (click)="dialogRef.close()" >Cancel</button>
</td>
</tr>
</table>

1 个答案:

答案 0 :(得分:0)

这样做:

<input name="file" type="file" class="inputfile" (change)="onFileChange($event)"/>

然后您可以在.ts文件中的onFileChange函数中处理上传的文件...