How do I show the user only jpeg files when browsing

R

Ron Brennan

Good afternoon.

I am trying to have the input element show only jpeg files when the user
browses his directories to choose an image to upload. This is what I think
should work but doesn't, at least for me using IE 5.0. Anyone out there that
can offer a possible solution?

<form action="myuploadservlet" method="post" enctype="multipart/form-data">
....
<input type="file" name="pic" accept="image/jpg,jpeg">

Thanks,
Ron.
 
L

Leif K-Brooks

Ron said:
<input type="file" name="pic" accept="image/jpg,jpeg">

That says that you'll accept the non-existant MIME types "image/jpg" and
"jpeg". You'll want to use accept="image/jpeg"; don't worry about the
file's extension. Unfortunately, though, there's virtually no browser
support for that attribute.
 
R

Ron Brennan

Leif K-Brooks said:
That says that you'll accept the non-existant MIME types "image/jpg" and
"jpeg". You'll want to use accept="image/jpeg"; don't worry about the
file's extension. Unfortunately, though, there's virtually no browser
support for that attribute.

I gained three pieces of information from you: 1) the image/jpg,jpeg syntax
is invalid 2) a correct MIME type will accept both extensions 3) virtually
no browser support for the attribute.

Much appreciated; thank you.

Ron.
 
L

Leif K-Brooks

Ron said:
The image/jpg,jpeg syntax is invalid

The syntax itself isn't invalid; it's valid syntax for saying "files of
the MIME types 'image/jpg' and 'jpeg'." It's just that neither of those
MIME types actually exist; a browser which supported the "accept"
attribute wouldn't display any files.

I'm guessing you meant to say "files of the MIME types 'image/jpg' and
'image/jpeg'." The correct syntax for that would be
"image/jpg,image/jpeg", although there's no reason to include the
"image/jpg".
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top