简体   繁体   English

如何在不刷新页面的情况下多次使用 p-fileupload 组件上传文件?

[英]How can I upload file by using p-fileupload component more than one time without refreshing Page?

I am using p-fileupload component in angular, but after uploading one file the button is not allowing click event, need to refresh Page to perform another file upload task.我在角度使用 p-fileupload 组件,但是在上传一个文件后,按钮不允许点击事件,需要刷新页面以执行另一个文件上传任务。 Can you please help how can I upload file without refreshing Page你能帮我在不刷新页面的情况下上传文件吗

Please find below html code:请在下面找到html代码:

<p-fileupload mode="basic" 
              [auto]="true" 
              title="upload file" 
              (onSelect)="upload_document($event);" 
              appHide[roles]=GRANT_ALL_GRP>
</p-fileupload>

If you use an array with file(name)s, then after the upload, you can clear the array and then the upload is possible again.如果您使用带有文件(名称)的数组,则在上传后,您可以清除数组,然后再次上传。

<p-fileUpload
   mode="basic"
   [auto]="true"
   [files]="myFiles"
   title="upload file"
   name="myfile[]" 
   [customUpload]="true"
   (uploadHandler)="upload_document($event);" >
</p-fileUpload>

In the component:在组件中:


myFiles: [] = [];

upload_document($event:any){
   console.log("Upload",$event);
   // UPLOAD LOGIC
   this.myFiles = [];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM