This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes IOException while retrieving file path from <input type=file> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "IOException while retrieving file path from &lt;input type=file&gt;" Watch "IOException while retrieving file path from &lt;input type=file&gt;" New topic
Author

IOException while retrieving file path from &lt;input type=file&gt;

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 222

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


Oracle Java Programmer , Oracle SQL Expert
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IOException while retrieving file path from &lt;input type=file&gt;
 
Similar Threads
Form is not submitting on TAB navigation
javax.imageio.IIOException: Can't create an ImageInputStream!
Image on file upload browse button
Form is not submitting when I use the TAB for navigation
reading a private method within a class