Processing of form's enctype = "multipart/form-Data"

Source: Internet
Author: User

 

Diskfileupload upload = new diskfileupload ();
Upload. setsizemax (size );
Try {
Items = upload. parserequest (request );
} Catch (exception _ ex ){
Error = "the attachment is too large! ";
Request. setattribute ("error", error );
Return Mapping. findforward ("failure ");
}
Iterator iter = items. iterator ();
While (ITER. hasnext ()){
Fileitem item = (fileitem) ITER. Next ();
If (item. isformfield () {// if it is a normal form
If (item. getfieldname (). Equals ("board_id ")){
Board_id = item. getstring ();
} Else if (item. getfieldname (). Equals ("tznr ")){
Article_content = item. getstring ();
} Else if (item. getfieldname (). Equals ("artice_title ")){
Artice_title = item. getstring ();
} Else if (item. getfieldname (). Equals ("article_id ")){
Re_artice_id = item. getstring ();
// System. Out. println ("re_artice_id =" + re_artice_id );
}
} Else {// if it is a file field form
Is = item. getinputstream (); // gets the input stream of the uploaded file
Size = item. getsize (); // File Size
Filename = item. getname ();
If (! Filename. Equals ("")){
Filename = filename. substring (filename. lastindexof ("\") + 1 );
Filename_exec = filename. substring (filename. lastindexof (".") + 1 );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.