如何在Kendo Angular Upload中将上传的文件发布到单独的按钮上,而不是自动上传

时间:2019-08-17 16:11:25

标签: angular kendo-ui angular5 kendo-ui-angular2 kendo-upload

我正在使用kendo-ui-angular上传。它具有自动上传功能,即使我们设置了auto-upload:false,它也会生成一个上传按钮。但是我有“表单提交”按钮,不需要在上传时从中提交文件。

<kendo-upload required
                        name="expertUpload" #expertUpload="ngModel"
                        [multiple]="false"
                        [saveUrl]="saveUrl"
                        [removeUrl]="uploadRemoveUrl"
                        (remove)="removeEventHandler($event)"
                        [restrictions]="fileRestrictions"
                        (success)="successEventHandler($event)"
                        [(ngModel)]="myFiles">
</kendo-upload>

我可以在进行HTTP POST调用时使用[(ngModel)] =“ myFiles”。如果是,那么它的WepAPI参数数据类型是什么?

1 个答案:

答案 0 :(得分:0)

我认为您无法使用此控件来做到这一点。我使用上载事件来调用我的自定义方法,以将自定义数据构建到fromdata对象中并发布到服务中。

(upload)="uploadEventHandler($event)"

uploadEventHandler(e: UploadEvent) {
for (const file of e.files) {
//your code to handle fileinfo build formdata
}
//post code
}

我没有对saveUrl进行任何操作,也没有将removeUrl允许其上传到Uploadinterceptor。但是我需要更好地处理进度条,我的代码仍在进行中。