My web app has a JSF2.0 page that looks more or less like this:
I nee开发者_运维百科d to preview the image, before i upload it and save it to the file system:
Do you know is there any library that can help me do that easily? I use primefaces fileupload gadget currently, but i don't know how to just preview and then upload.
Could you give me some best practice tips on from where to start, in order to achieve my goal.
is very complex...theoretically is possible but complex.. when upload the file you should save the stream (byte[]) in the session of the user and after that make the img src url for a servlet that responds with the bytes saved earlier... this is the theory...I don't know if there is something implemented...
I am sorry to disappoint you but I do not think it is possible at all with HTML. Browser allows you to upload files but you cannot get their content or file system path. So, the solution is to upload file first and then show its preview using AJAX.
Probably Flash or Flex give you this functionality, so, I'd recommend you to check these tools. And obviously you can use Java applet but it will limit your user base.
精彩评论