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

S

Smurf

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?
 
S

Sudsy

Smurf wrote:
/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
 
S

Sudsy

Smurf wrote:
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.
 
S

Smurf

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
 
Joined
May 11, 2012
Messages
2
Reaction score
0
<input type="file" name="picture" accept="image/*">

Try this and it should work, this also filter jpg, png, bmp, and gif
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top