1 <Div>2 <inputtype= "File"ID= "Uploadify"name= "Uploadify" />3 </Div>4 <Div>5 <ahref= "javascript:$ (' #uploadify '). Uploadify (' upload ');">Upload</a>6 </Div>
Js
1$(function () {2$ (' #uploadify '). uploadify ({3Width:60,//width of the button4Height:23,//the height of the button5Method: "Get",6ButtonText: "Select File",7Buttoncursor: ' Hand ',//button's mouse icon8 //fileobjname: ' Filedata ',//upload parameter name9 //Two matching useTenFiletypeexts: "*.xls;",//Extended Name OneFILETYPEDESC: "Please select XLS file",//Document Description AQueueid: "Filequeue", -' Auto ':false, -' swf ': '/content/script/uploadify/uploadify.swf ', the' Uploader ': '/report/consumptionandutilization/upload ', -' Onuploadstart ':function(file) { - varZtree = $.fn.ztree.getztreeobj ("Treedemo"); - varCheckcount = Ztree.getcheckednodes (true); + varOrgID = checkcount[0]. OrganizationId; -$ ("#uploadify"). Uploadify ("Settings", "FormData", {' Date ': $ ("#textBegindate"). Val (), ' OrgID ': OrgID}); + A at } -});
C#
1 Publicactionresult Upload (httppostedfilebase Filedata)2 {3 4 5 6 //If the file is not uploaded7 if(Filedata = =NULL||8 string. IsNullOrEmpty (filedata.filename) | |9Filedata.contentlength = =0)Ten { One return This. Httpnotfound (); A } - - //save to the ~/photos folder, the name does not change the //string filename = System.IO.Path.GetFileName (filedata.filename); - stringfilename = request.querystring["Date"] +"_"+ request.querystring["OrgID"] +". xls"; - stringVirtualPath = + string. Format ("~/report/consumptionandutilization/monthly/tables/{0}", filename); - //The file system cannot use the virtual path + stringPath = This. Server.MapPath (virtualpath); A filedata.saveas (path); at - - return This. Json (New { }); -}
Uploadify Using Tutorials