<html:file> accept property and button's label

Discussion in 'Java' started by Smurf, Jul 27, 2004.

  1. Smurf

    Smurf Guest

    The statement:
    - Using struts
    - A <html:file> tag in a form

    The issues:
    /1/ accept
    I'd like to limit the option of the browser filtering only the file *.jpg.
    I though this should perform:
    <html:file property="fileLoader" accept="*.jpg"/>
    but not.

    Could you tell me what's wrong?

    /2/ label
    Furthermore I could not set the label of the button.
    <html:file property="fileLoader">Something</html:file>
    neither perform.

    It is possible to customise this button? How?
    Smurf, Jul 27, 2004
    #1
    1. Advertising

  2. Smurf

    Sudsy Guest

    Smurf wrote:
    <snip>
    > /1/ accept
    > I'd like to limit the option of the browser filtering only the file *.jpg.
    > I though this should perform:
    > <html:file property="fileLoader" accept="*.jpg"/>
    > but not.
    >
    > Could you tell me what's wrong?


    You have to read the javadocs vewwy, vewwy, cawefully...
    Here's what it says about the accept attribute:
    "Comma-delimited set of content types ..."
    Note the use of the term 'content type'. What you provided
    was a filename pattern, namely '*.jpg'.
    Now if you go to the RFCs, namely RFC 2046, you'll find the
    specification of content types. You'll also find that JPEG
    maps to a content type of 'image/jpeg'. Try using that as
    the value of the accept attribute.

    HTH
    Sudsy, Jul 27, 2004
    #2
    1. Advertising

  3. Smurf

    Sudsy Guest

    Smurf wrote:
    <snip>
    > I also try
    >
    > <html:form method= "POST" enctype= "multipart/form-data"
    > action="doSomething.do">
    > ...
    > <html:file property="fileLoader" accept="image/jpeg"/>
    > ...
    > </html>
    > It also doesn't perform.


    Apart from the spaces in the html:form tag (hopefully just
    a transcription error), could you be more specific in how
    it "doesn't perform"?
    Do you get errors in your browser? Do you see internal
    errors? Can you "View Page Source" and see that the tags
    are recognized? Are you seeing the proper HTML?
    Sorry, but without a bit more information I'd just be
    taking shots in the dark. Do us both a favour and create
    a self-contained example which is visible from the 'net.
    (search the archives for Andrew's site)

    ps. I KNOW that the approach I posted works since I use
    it in a functional web application.
    Sudsy, Jul 28, 2004
    #3
  4. Smurf

    Smurf Guest

    (Smurf) wrote in message news:<>...
    > The statement:
    > - Using struts
    > - A <html:file> tag in a form
    >
    > The issues:
    > /1/ accept
    > I'd like to limit the option of the browser filtering only the file *.jpg.
    > I though this should perform:
    > <html:file property="fileLoader" accept="*.jpg"/>
    > but not.
    >
    > Could you tell me what's wrong?
    >
    > /2/ label
    > Furthermore I could not set the label of the button.
    > <html:file property="fileLoader">Something</html:file>
    > neither perform.
    >
    > It is possible to customise this button? How?





    I also try

    <html:form method= "POST" enctype= "multipart/form-data"
    action="doSomething.do">
    ...
    <html:file property="fileLoader" accept="image/jpeg"/>
    ...
    </html>
    It also doesn't perform.


    I try it in html:
    <input type="file" name="fileLoader" accept="image/jpeg"/>
    It neither performs.

    In Microsoft document it's writen that the "accept" attribute is new
    but not how new it is.
    I run my work in IE 6.0, is this version already too old?
    For struts, should I look for a struts-html.tld more up to date?

    I'll be really gratefull if you could help me.
    Thanks in advance
    Smurf, Jul 28, 2004
    #4
  5. Smurf

    isoft

    Joined:
    May 11, 2012
    Messages:
    2
    <input type="file" name="picture" id="picture" accept="image/*">
    isoft, May 11, 2012
    #5
  6. Smurf

    isoft

    Joined:
    May 11, 2012
    Messages:
    2
    <input type="file" name="picture" accept="image/*">

    Try this and it should work, this also filter jpg, png, bmp, and gif
    isoft, May 11, 2012
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Garg Pankaj

    HtmlInputFile accept property

    Garg Pankaj, Aug 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,404
    bruce barker
    Aug 26, 2003
  2. Vinod I
    Replies:
    1
    Views:
    375
    Brian K. Williams
    Feb 26, 2004
  3. ALok Gupta via .NET 247
    Replies:
    2
    Views:
    1,113
    John Saunders
    Aug 9, 2004
  4. CSharpner
    Replies:
    0
    Views:
    1,010
    CSharpner
    Apr 9, 2007
  5. Knut Krueger
    Replies:
    8
    Views:
    263
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page