Ext.js multiple file selection upload,

Source: Internet
Author: User

Work came to a company with Ext.js, at the beginning of the project, I was assigned to a single table to add and delete, plus file upload function, take my teacher let me study how to ext.js how to upload files, and can get to upload the file name and various properties, At first, it was a headache, later know that this thing actually later also changed the code to HTML tags, upload the document is <input type= "file"/>, but then how can not be passed to the backstage servlet, Later on the input tag added a Name property, it can run normally, but so directly a input tag display in Ext inside looks very strange, then take my teacher wants to start to change the source code, below is the focus of the beginning:

First with a input embedded in ext inside the picture, does not show very good

Then found the file upload the source code, is this file

Change the source of the opposite

Switch

    //ext switch to the input tag code, change the properties, add a multiple propertyCreatefileinput:function() {        if( This. multiple!=NULL){//make a judgment.              This. FileInput = This. Wrap.createchild ({ID: This. Getfileinputid (), Name: This. name| | This. GetId (), CLS:' X-form-file ', Tag:' Input ', multiple:' Multiple ',//Add multiple hereType: ' File ', Size:1             }); }Else{             This. FileInput = This. Wrap.createchild ({ID: This. Getfileinputid (), Name: This. name| | This. GetId (), CLS:' X-form-file ', Tag:' Input ', type:' File ', Size:1            }); }    }

Set automatic display file name

Changefunction(){                //debugger into the commissioning mode;                if( This. multiple!=NULL){                    varv = This. FileInput.dom.files; varval = ';  for(vari=0;i<v.length;i++){                        if(i==0) {Val= val+V[i].name; }Else{val= Val+ ', ' +V[i].name; }                    }                      This. SetValue (Val);  This. FireEvent (' fileselected ', This, Val); }Else{                    varv = This. FileInput.dom.value;  This. SetValue (v);  This. FireEvent (' fileselected ', This, V); }            }

This allows you to write the multiple attribute directly in the foreground code, and also supports multiple file selection uploads.

Ext.js multiple file selection upload,

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.