• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IOException while retrieving file path from <input type=file>

 
Ranch Hand
Posts: 391
1
MySQL Database PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i try to retrieve the image file from the jsp page from the <input> tag it gives excception.

I`m construting my File using the file path that is selected by user in the <input> tag

<input type=file accept=image/gif name='browse'>
String s=req.getParameter(browse);

File f=new File(s); //this line results in runtime exception IIOException

but when directly give it absolute path of image like File f=new File("C:\Users\Mahtab\Desktop\pic.gif");
it works without exception.

So the problem is in constructing the File object .


Please give some solution to this problem
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot use file I/O to upload a file. File I/O can only access local files. Please see the ServletsFaq for information on how to upload files.
 
reply
    Bookmark Topic Watch Topic
  • New Topic