• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!