1

Is there any way to fire the basic <p:fileUpload> button (the one that shows a panel to select a file) on click of an image?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

3

Just put the image in a label referring the input field.

<h:form>
    <p:fileUpload id="file" mode="simple" ... />
    <h:outputLabel for="file">
        <p:graphicImage name="images/pic.png" />
    </h:outputLabel>
</h:form>

Do note that this works even if the input is hidden by CSS.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555