asp.net mvc using uploadify upload files

Source: Internet
Author: User
Tags min

The curriculum design needs to realize the uploading file module, originally ASP.net has the built-in control, but ASP.net mvc does not have, therefore has two kinds of methods: customizes and adopts the third party plug-in. Due to the relationship between time, so the use of Third-party plug-ins: Uploadify.

Uploadify use must download the corresponding file, download address: http://www.uploadify.com/download/.

First view:

<asp:content id= "Content3" contentplaceholderid= "Head" runat= "Server" > <script src= "/scripts/swfobject.js" Type= "Text/javascript" ></script> <script src= "/scripts/jquery-1.4.1.min.js" type= "Text/javascript" ></script> <script src= "/scripts/jquery.uploadify.v2.1.0.min.js" type= "Text/javascript" ></ script> <link href= "/content/uploadify.css" rel= "stylesheet" type= "Text/css"/> <style type= "text /css ">.
            Successtext {color:red;
        Font-weight:bold; }
    
        .
            Failetext {color:green;
        Font-weight:bold; } </style> <script type= "Text/javascript" > $ (Function () {$ (' #fileInput1 '). u
                Ploadify ({' Uploader ': '/content/uploadify.swf ', ' script ': '/home/loadfile ',
 ' Folder ': '/uploadfiles ', ' cancelimg ': '/content/cancel.png ',               ' SizeLimit ': 1024 * 1024 * 4,//4m ' multi ': true, ' oncomplete ': Complete
    
        });
        }); function Complete (event, Queueid, Fileobj, response, data) {if (Response!= "") {Showinfo ("into
            Work upload "+ response, true); } else {Showinfo ("Error on file!")
            ", false); }//Display the hint message, Successtext is green, that is, upload succeeded; Falsetext is red, that is, upload failure function showinfo (msg, type) {V Ar msgclass = Type = = True?
            "Successtext": "Failetext";
            $ ("#result"). Removeclass ();
            $ ("#result"). addclass (Msgclass);
        $ ("#result"). HTML (msg); //If the Select File is blank when you click on ' import file ', Prompt for function checkload () {if $.trim ($ (' #fileInput1Queue '). html () = = " ") {alert (' Please select the file to upload first!
                ');
            return false;
        return true; } </script> </asp:Content> <aSp:content id= "Content2" contentplaceholderid= "maincontent" runat= "Server" > <p> <p> <input id= "fileInput1" name= "fileInput1" type= "file"/> </p> <p style= "margin-top:5p X font-size:14px; Font-weight:bold; " > <a href= "javascript:if (Checkload ()) {$ (' #fileInput1 '). Uploadifysettings (' Scriptdata ', {' name ': $ (' #test '). Val ()}); $ (' #fileInput1 '). Uploadifyupload ();} " > Upload </a> </p> <p style= "margin-top:5px; font-size:14px; Font-weight:bold; " ><span id= "Result" ></span></p> </p> </asp:Content>

Related Article

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.