File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes File upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "File upload" Watch "File upload" New topic
Author

File upload

Nit Kul
Greenhorn

Joined: Oct 26, 2009
Posts: 14
Hi,

In JSP <input type="file/> gives an option to choose local file using the file chooser menu.
How can I restrict this menu, to allow users to upload just JPG files?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Not a JSP question. Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

You can't. You'll have to check it on the server after the upload.
Nit Kul
Greenhorn

Joined: Oct 26, 2009
Posts: 14
Hi Thanks for reply,

<input TYPE="file" name="filename" accept="image/jpg"/>

I used accept option, after reading it in some of other forums. But this did not work.
Is there anyway I could make accept work?

Thanks again
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The answer is still no--most (all?) browsers ignore the attribute.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File upload
 
Similar Threads
Encoding problem with File Upload
How to write the code to upload images?
sending a file to servlet
Opening File Chooser in a jsp Page?
calling getInputStream after getParameter