How to Use smartupload to upload a file to obtain the text field value

Source: Internet
Author: User

I made a file upload page a few days ago and found that smartupload is quite useful, but I need to set form to enctype = "multipart/form-Data", then go to the action page and use request. the getparameter method cannot obtain the value of the text field. I haven't found it online for half a day. Later, I thought of a way to divide the page into two forms, one for uploading files and directing the action to an ifram in the form. Another form is responsible for the submission of text field values. Click "Submit" and use js to control it. First, submit the form of the file to be uploaded. Then, after the file is uploaded, submit the form of the text field.
This mode also seems to have a benefit. After selecting a file, you can upload the file when entering the form field value. After the file is uploaded, you can directly submit the page, it seems a bit similar to the Gmail attachment upload effect. When I use a Gmail mailbox to send an email, I encounter a large attachment. Generally, I select the attachment to upload and write the body of the email during the attachment transfer process. After the mail is completed, the attachment is almost uploaded.

However, I accidentally searched an article on the internet today and found that files and files can be submitted simultaneously using smartupload. The method described in this article is as follows.
---------------------------
In the form, enctype = "multipart/form-Data" indicates the mime encoding of the form. By default, the encoding format is application/X-WWW-form-urlencoded and cannot be used for file upload. Only multipart/form-data is used, can complete the transfer of file data, but set enctype = "multipart/form-Data", in addition to the file type form can be obtained, other values through the request. getparameter cannot be obtained. In this case, we can use components to solve this problem, for example, using the jspsmartupload component.
Com. jspsmart. Upload. smartupload su = new COM. jspsmart. Upload. smartupload ();
Su. initialize (pagecontext );
Su. Service (request, response );
Su. settotalmaxfilesize (100000000 );
Su. setallowedfileslist ("Zip, rar ");
Su. setdeniedfileslist ("EXE, bat, JSP, htm, HTML ,,");
Su. Upload ();

 

String name = Su. getrequest (). getparameter ("name ");
String type_id = Su. getrequest (). getparameter ("type ");

By Su. getrequest (). getparameter ("value"); then, Su. upload () seems to have to be put in front, and Su will be in the test. failed to put upload () after obtaining the parameter.

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.