jquery's ajaxfileupload asynchronous upload

Source: Internet
Author: User

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

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.