如何使用p-fileupload组件多次使用刷新页面上传文件?

发布于 2025-02-11 01:41:38 字数 395 浏览 1 评论 0原文

我在Angular中使用p-fileupload组件,但是在上传一个文件后,按钮不允许单击事件,需要刷新页面以执行另一个文件上传任务。您可以帮助您如何上传文件而不刷新页面,

请在下面找到HTML代码:

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

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. Can you please help how can I upload file without refreshing Page

Please find below html code:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2025-02-18 01:41:38

如果将数组与文件(名称)s一起使用,则在上传后,可以清除数组,然后再次上传。

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

在组件中:


myFiles: [] = [];

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

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 = [];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文