开发者

how to pass text value along with multiple file upload form

I am having one file upload form which uploads multiple files. Right now I have hard coded the folder name in which the uploaded file is to be stored.

But what I need is at the time of upload the form should also send folder name which will be created on the server to store uploaded files.

This is my form

 <form action="uploadprocess.jsp" method="post" enctype="multipart/form-data" name="for开发者_StackOverflow中文版m1" id="form1">
<input name="file" type="file" id="file">
<input name="file" type="file" id="file">

<input name="foldername" type="hidden"> <!-- i will set folder name during run time -->
</form>

I am getting null when I use request.getParameter("foldername")


Because of enctype="multipart/form-data". To get value from a form of "multipart/form-data" you need to use MultipartRequest.When you use multipart form you can access parameters on request object.

See this: get-form-parameters-from-multipart-request to know how to get parameter in multipart request.

Else try this:

  1. download http://www.servlets.com/cos/index.html
  2. invoke getParameters() on com.oreilly.servlet.MultipartRequest
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜