jquery Upload Plugin uploadify

Source: Internet
Author: User

One: Official website

http://www.uploadify.com/

II: References

<link href= "Plug-in/uploadify3.2.1/uploadify.css" rel= "stylesheet"/>
<script type= "Text/javascript" src= "Plug-in/uploadify3.2.1/jquery.uploadify.min.js" ></script>

Three: examples

(1) Front page

<TR>        <TDAlign= "Right">            <labelclass= "Validform_label">Theme Map:</label>        </TD>        <TDclass= "value">             <inputID= "Subjectmap"name= "Subjectmap"type= "hidden"datatype="*" />             <Table>                <TR>                    <TD>                        <inputtype= "File"name= "Upload_org_code"ID= "Upload_org_code"/>                    </TD>                    <TD>                       <imgID= "Upload_org_code_img"src=""width= "216"Height= "135">                       <aID= "Del"style= "Display:none;"href="#"onclick= "del ()">Delete</a>                    </TD>                </TR>             </Table>             <spanclass= "Validform_checktip">Recommended Size: 720*360</span>        </TD></TR>

(2) Upload JS

SetTimeout (function () {$ ("#upload_org_code"). Uploadify ({' Height ': 27, ' Width ': $, ' buttontext ': ' Image upload ', ' swf ': ' Plug-in/uploa dify3.2.1/uploadify.swf ', ' uploader ': ' roulettecontroller.do?objupload ', ' Auto                    ': True, ' multi ': false, ' removecompleted ': true,                    ' Removetimeout ': 1, ' cancelimg ': ' Plug-in/uploadify3.2.1/uploadify-cancel.png ', ' filetypeexts ': ' *.jpg;*.jpge;*.gif;*.png ', ' filesizelimit ': ' 2MB ', ' Onuploa '                         Dsuccess ': function (file,data,response) {var json = eval (' (' + data + ') ');                        var url=json.attributes.visiturl+json.attributes.filename;                      $ ("#upload_org_code_img"). attr ("src", url);   $ ("#subjectMap"). Val (Json.attributes.fileName);                    $ ("#del"). attr ("style", "display:block;");},//Plus this sentence overrides the Onselecterror method "event to override"                    ' Overrideevents ': [' onselecterror ', ' ondialogclose '],//Return an error, trigger when selecting a file                            ' Onselecterror ': function (file, ErrorCode, errormsg) {switch (ErrorCode) { Case-110:alert ("File [" +file.name+ "] size exceeds system limit" + jQuery (' #upload_ Org_code '). Uploadify (' Settings ', ' filesizelimit ') + "size!                                ");                            Break Case-120:alert ("File [" +file.name+ "] size is abnormal!                                ");                            Break Case-130:alert ("File [" +file.name+ "] type is incorrect!                                ");                        Break        }                    },        });   },10)

(3) Upload background code

/*** * image upload **/@RequestMapping (params= "Objupload") @ResponseBody PublicAjaxjson objupload (HttpServletRequest request)throwsException {Ajaxjson J=NewAjaxjson (); Map<string, object> attributes =NewHashmap<string, object>(); Multiparthttpservletrequest multipartrequest=(multiparthttpservletrequest) request; Map<string, multipartfile> filemap =Multipartrequest.getfilemap (); String Tomcaturl= Propertiesconfig.getstringconfig ("Tomcaturl"); String Roulette_sub_url= Propertiesconfig.getstringconfig ("Roulette_sub_url"); String Visiturl= Propertiesconfig.getstringconfig ("Visiturl"); //Create a folderFile File =NewFile (tomcaturl+Roulette_sub_url); if(!file.exists ())        {File.mkdirs (); } String fileName=NULL; //String path = null;         for(Map.entry<string, multipartfile>Entity:fileMap.entrySet ()) {            //Upload file nameMultipartfile MF =Entity.getvalue (); FileName=Mf.getoriginalfilename (); String Fileext= Filename.substring (Filename.lastindexof (".") + 1). toLowerCase (); SimpleDateFormat DF=NewSimpleDateFormat ("Yyyymmddhhmmss"); String NewFileName= "Roulette_" + Df.format (NewDate ()) + "_bak" + "." +Fileext; File UploadFile=NewFile (tomcaturl+roulette_sub_url+newfilename); Try{filecopyutils.copy (Mf.getbytes (), uploadfile); FileName= roulette_sub_url+NewFileName; } Catch(IOException e) {e.printstacktrace (); }} attributes.put ("Visiturl", Visiturl); Attributes.put ("FileName", FileName);        J.setattributes (attributes); returnJ; }
View Code

jquery Upload Plugin uploadify

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.