0

My Question is simple. I want to upload the file (not the external location) within the server; say in WEB-INF/files (if it's a good idea. So far I have uploaded the file to the external location but the problem is I can not display the file (image) back to the details.xml

Here is my code:

image upload and saving the location to Database via Hibernate(not concerned here).

<h:form enctype="multipart/form-data">
    <h:panelGrid columns="1">   
        <h:panelGroup>
            <p:fileUpload fileLimit="1" auto="true" fileUploadListener="#{employeeManagedBean.upload}" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" sizeLimit="100000" description="Upload Image" required="true" />
        </h:panelGroup>

    </h:panelGrid>
</h:form>

and here is the snippet from details.xml which should have shown the picture (but doesn't, although the link to that image shown in the rendered page is correct).

<h:graphicImage value="#{employeeManagedBean.image}"/>

Where am I messing up. I am newbie!

Imam Bux
  • 1,006
  • 11
  • 27
  • You say `#{employeeManagedBean.image}` evaluates to a valid path to the image? What happens if you just try with ``? That way you need the image to be publicly accessible by the user (it won't work if you store it in WEB-INF). However, Primefaces has a nice feature to display streamed content from a bean, check it out: http://www.primefaces.org/showcase/ui/multimedia/graphicImage.xhtml – Aritz May 12 '15 at 11:22
  • What is your actual problem? Upload image to interal location or image not getting rendered. – Parkash Kumar May 12 '15 at 11:43
  • The right solution to your problem of being unable to serve from external location is answered in the dupe. The concrete problem of saving files in deploy folder is answered here: http://stackoverflow.com/questions/8885201/uploaded-image-only-available-after-refreshing-the-page – BalusC May 12 '15 at 11:45

0 Answers0