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,