Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
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
Pie
Posts: 65114
89
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic