简体   繁体   English

Primefaces p:fileupload获取所有图片

[英]Primefaces p:fileupload get all the pictures

I wanna know how could I get all the pictures from a P:FILEUPLOAD in only one event upload. 我想知道如何仅通过一次事件上传就可以从P:FILEUPLOAD获取所有图片。

1.- 1.-

<p:fileUpload 
    mode="advanced" 
    update="messages" 
    fileLimit="10" 
    allowTypes="/(\.|\/)(gif|jpe?g|png)$/" 
    sequential="true" 
    process="@this" 
    fileUploadListener="#{publicacionesController.handleFileUpload}"/>

2.- 2-

public void handleFileUpload(FileUploadEvent event) {
    FacesMessage message = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
    System.out.println("El size lista1: " + imgs.size());
    imgs.add(event.getFile());
    System.out.println("El size lista2: " + imgs.size());

    FacesContext.getCurrentInstance().addMessage(null, message);
}

I need load the 10 in my list "imgs" but the every picture load in a diferent event and when I try to use my list only has one picture (the last in the event). 我需要在列表“ imgs”中加载10张图片,但是在不同事件中加载的每张图片,当我尝试使用列表时,仅包含一张图片(该事件中的最后一张)。

I wanna know how could I get all the pictures from a P:FILEUPLOAD in only one event upload. 我想知道如何仅通过一次事件上传就可以从P:FILEUPLOAD获取所有图片。

As stated in PrimeFaces Documentation , this is not possible: PrimeFaces文档中所述 ,这是不可能的:

Multiple Uploads 多次上传

... Note that multiple mode is for selection only, it does not send all files in one request. ...请注意,多种模式仅用于选择,它不会在一个请求中发送所有文件。 FileUpload component always uses a new request for each file. FileUpload组件始终对每个文件使用一个新请求。

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

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