wood burning stoves 2.0*
The moose likes Servlets and the fly likes input type = file problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "input type = file problem" Watch "input type = file problem" New topic
Author

input type = file problem

saravanan balakrishnan
Greenhorn

Joined: Jun 05, 2001
Posts: 5
hi,
i'm using <input type="file" name="filename1"> in my jsp.when i was trying to get the parameter in my servlet using getParameter method,i'm getting only null.why is it?
can u give me some solution for this.
thanx
Metal God
Greenhorn

Joined: Jun 05, 2001
Posts: 2
Hi Bala
Precisely what you wanted to retrieve? do you want to retrieve a file contents or the filename?
MG
phongtran
Greenhorn

Joined: May 29, 2001
Posts: 4
Hi Bala
Because <input type="file" name="filename1"> is used only for MultiPart form.
So that you must use multipart.getParammter()
About MultiPart, please contact him
// Copyright (C) 1998 by Jason Hunter <jhunter@acm.org>. All rights reserved.
// Use of this class is limited. Please see the LICENSE for more information.
OR, you can download some java class (package cos.jar)
com.oreilly.servlet.multipart.MultipartParser;
com.oreilly.servlet.multipart.Part;
com.oreilly.servlet.multipart.FilePart;
com.oreilly.servlet.multipart.ParamPart;

Bye
Quoc Phong

Tran Quoc Phong
saravanan balakrishnan
Greenhorn

Joined: Jun 05, 2001
Posts: 5
hi,
thanx guys for the reply.
i need the filename(from my local system,for example,C:\com\) to my servlet.is there any other method other than Multipart?
thanx
phongtran
Greenhorn

Joined: May 29, 2001
Posts: 4
Hi
You can to use hidden field in your form
When you submit, you use JavaScript to get your fileName
And then, in your servlet, you must use mutilPart.getParameter() to get your fileName
Example:
In your HTML file
<FORM NAME="UploadFile" ACTION="" ENCTYPE="multipart/form-data" METHOD=POST>
<input type="FILE" name="file" value="">
<input type="hidden" name="fileName" value="">
</FORM>
<script language="JavaScript">
function onSubmit() {
fileName.value = file.value;
}
</script>
In your Servlet file
fileName = multiPart.getParameter("fileName");
Have fun, this is my idea, ;-)
Quoc Phong
 
 
subject: input type = file problem
 
Similar Threads
How To Make the "Browse ..." Button Work?
How to open Open File window using Javascript?
read the full file path
Problem with image as submit button
FTPing files from HTML form