JS Code
1 functionajaxfileupload () {2 varloading= ' <li class= "close loading" ></li> ';3$ (' #aaa ').append (loading);4$ (' #loading '). Bind ("click",function(){5$ (' #openwinbg01 '). CSS ("Display", "block");6$ (' #openwin01 '). CSS ("Display", "block");7 });8$.Ajaxfileupload9 (Ten { OneURL: "./index.php?g=wap&m=junk&a=upload",//server-side request address for file uploads ASecureuri:false,//generally set to false -Fileelementid: ' File1 ',//file upload Space id attribute <input type= "file" id= "file" name= "file"/> -DataType: ' JSON ',//The return value type is generally set to JSON theSuccessfunction(data)//Server Success Response handler function - { -$ ('. Loading ').remove (); - //alert (111); + //Var img=$ (' #imgio '). Val (); - vardlid=$ (' #io '). Val () *; + //var img= "<dl><button class= ' close ' > Delete </button></dl > "; A varimg= ' <li data-role= "img" class= "Close Clo" id= "' +dlid+ '" ></li> "; at$ ("#aaa").Append (img); - vario=$ (' #io '). Val () *1+1; -$ ("#io"). attr (' value ',io); - -}, -Errorfunction(data, status, E)//Server Response Failure handler function in { - alert (e); to}, +Complete:function(){ - the$ ('. Clo '). Bind ("click",function(){ *$ (' #openwinbg '). CSS ("Display", "block"); $$ (' #openwin '). CSS ("Display", "block");Panax Notoginseng varII = $ (this). attr (' id ') *1+1; - //alert (ii); the$ (' #ii '). attr (' value '),II); + }); A } the } + ) - return false; $}
HTML code
1 <input type= "file" capture= "Camera" class= "Input-file" name= "File1" id= "File1" onchange= " Ajaxfileupload () "/>
Thinkphp acquired code
1 //File Upload2 Public functionupload () {3Import ("@.org.uploadfile");4 $upload=NewUploadFile ();//instantiating an upload class5 $upload->maxsize = 31457280000;//set attachment upload size6 //$upload->allowexts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type7 $upload->savepath = './uploads/file/'.Date(' Ymd '). ' /‘;//Set Attachments upload directory8 $upload->imageclasspath = ' @.org.image ';9 //settings need to generate thumbnails, only valid for image filesTen $upload->thumb =true; One //set the file suffix to generate thumbnails A $upload->thumbprefix = ' m_ ';//production of 2 thumbnail pictures - //Set thumbnail maximum width - $upload->thumbmaxwidth = ' 480 '; the //set thumbnail maximum height - $upload->thumbmaxheight = ' 320 '; - if(!$upload->upload ()) {//Upload error message - Echo0; +}Else{ - $info=$upload-getuploadfileinfo (); + Echo $upload->savepath. ' M_ '.$info[0] [' Savename ']; A } at}
jquery's ajaxfileupload asynchronous upload