问题描述:

I have project where users can select an image file from their computer and upload it to server. Other than only image data in the form I have another specification of the person who it belongs, Something like this:

<form method="POST" action="../upload" enctype="multipart/form-data" name="imgdata">

<div class="browsephoto_div">

<label class="takeapicture_btn">

<input type="file" name="ImagesFile" class="Propicselecter_file" id="Propicselecter_file" size="1" accept="image/*" id="imagetoupload" name="fname1"/>

<span>Browse</span>

</label>

</div>

<input type="text" class="se" name="se"/>

<input type="submit" class="CSFBTN" value="Finish"/>

</form>

As you can see <input class="se" contains the owner specifications. And here is the Server-Side receiving code:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

response.setContentType("text/html");

for(Part p : request.getParts() ) {

if( "se".equals(p.getName()) ) {

System.out.println("P: "+p.getName());

}

else {

System.out.println("Name: "+p.getName());

}

}

}

So far it works fine But The problem is that I don't know how to extract se data and to extract file data from the parts and write it to the hard disk.

Thanks in advance:)

相关阅读:
Top