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>