<inputtype= "File"value= "Select Picture"name= "Accountlicence"onchange= "Filechange (this, ' pic ')"class= "Inputtext selectbtn"><inputtype= "File"value= "Select Attachment"name= "Accountlicence"onchange= "Filechange (this, ' Doc ')"class= "Inputtext selectbtn">
Before the verification of the method of uploading attachments, simple display, although not perfect but also can use, the back will be set to write a form operation of the plug-in, finishing in ~
functionFilechange (target,docpic) {varFileSize = 0; varFilePath =Target.value; varAGT =window.navigator.userAgent; varIsie = Agt.tolowercase (). IndexOf ("MSIE")! =-1; if(Isie &&!)target.files) {varFileSystem =NewActiveXObject ("Scripting.FileSystemObject"); if(!filesystem.fileexists (FilePath)) {Dialog.alert ("The attachment does not exist, please re-enter!" "); return; } varFile =Filesystem.getfile (FilePath); FileSize=file. Size; } Else{fileSize= Target.files[0].size; } varSize = filesize/1024; if(docpic== "Doc" &&size>4000) {Dialog.alert ("Attachment size cannot be greater than 4m! ",function() {Target.value=""; }); } if(docpic== "pic" &&size>2000) {Dialog.alert ("Attachment size cannot be greater than 2m! ",function() {Target.value=""; }); } if(size<=0) {Dialog.alert ("The attachment size cannot be 0m! ",function() {Target.value=""; }); } //Get upload file name varFilearr=filepath.split ("\ \"); varFiletarr=filearr[filearr.length-1].tolowercase (). Split ("."); varFiletype=filetarr[filetarr.length-1]; //cut out suffix file name if(docpic== "pic" &&size<2000&&filetype! = "JPG" &&filetype! = "JPEG" &&filetype! = " GIF "&&filetype! =" png "&&filetype! =" BMP ") {Dialog.alert ("File type error!<br/> Please select" jpg/jpeg/gif/png/bmp "type",function() {Target.value=""; }); } if(docpic== "Doc" &&size<4000&&filetype! = "Doc" &&filetype! = "Docx" &&filetype! = " XLS "&&filetype! =" xlsx "&&filetype! =" PDF ") {Dialog.alert ("File type error!<br/> Please select" doc/docx/xls/xlsx/pdf "type",function() {Target.value=""; }); } }
Upload Attachment Verification method