1

please let me know that how can i upload an image using primeface fileUpload.i want to store the uploaded image into a folder and also want to resize the image using thumbnailator .i have already tried the primeface fileupload but not getting.

<p:fileUpload allowTypes="/(\.|\/)(gif|jpe?g|png)$/" auto="true" dragDropSupport="true" fileUploadListener="#{loginController.fileUploadHandler}" />

public void fileUploadHandler(FileUploadEvent event) throws IOException {
    UploadedFile file = event.getFile();
    InputStream inStream = file.getInputstream();
    Os.write("C:\\Users\\think again\\Desktop\\uploaded\\pic.jpg", inStream);
    Thumbnails.of(new File("C:\\Users\\think again\\Desktop\\uploaded").getAbsoluteFile()).size(100, 100).outputFormat("jpg").toFile("C:\\Users\\think again\\Desktop\\thumb");
}

but the file object contain a part item dont know what it is. will get the fileItem object inside the part.please help me to upload the image into the correspondding location

ngspkinga
  • 421
  • 5
  • 16
Ansar
  • 11
  • 4
  • try http://stackoverflow.com/questions/8875818/how-to-use-primefaces-pfileupload-listener-method-is-never-invoked?rq=1 – mehere Apr 15 '14 at 09:57
  • @EvesMary : my backing bean is session scoped.instead of showing uploaded messages i need to store the image into a file – Ansar Apr 15 '14 at 11:58