<%@ Page Language="C#" Debug="true"%><%@ Register TagPrefix="fup" Namespace="OboutInc.FileUpload" Assembly="FileUpload" %><%@ Import Namespace="System.IO" %><html xmlns="http://www.w3.org/1999/xhtml"><head><title>ASP.NET FileUploadProgress</title><script runat="server" language="c#"> void Page_load(object sender, EventArgs e) { if(Page.IsPostBack) { OboutFileCollection files = uploadProgress.Files; uploadedFiles.Text = ""; for(int i=0; i < files.Count; i ) { OboutPostedFile file = files[i]; file.SaveAs(MapPath("~/Uploaded/" Path.GetFileName(file.FileName))); if(uploadedFiles.Text.Length == 0) uploadedFiles.Text = "<b>成功上传文件:</b><table border=0 cellspacing=0>"; uploadedFiles.Text = "<tr>"; uploadedFiles.Text = "<td class='option2'>" Path.GetFileName(file.FileName) "</td>"; uploadedFiles.Text = "<td style='font:11px Verdana;'> " file.ContentLength .ToString() " bytes</td>"; uploadedFiles.Text = "<td class='option2'> (" file.ContentType ")</td>"; uploadedFiles.Text = "<td style='font:11px Verdana;'> <b>Input name</b>: \"" file.InputName "\"</td>"; uploadedFiles.Text = "</tr>"; } if(uploadedFiles.Text.Length==0) uploadedFiles.Text = "no files"; else uploadedFiles.Text = "</table>"; } }</script><script type="text/JavaScript">function Clear(){ document.getElementById("<%= uploadedFiles.ClientID %>").innerHTML = "";}function Cancel(){ <%= uploadProgress.ClientID %>_obj.CancelRequest();}function ServerException(mess){ alert(mess);}</script></head><body><br /><br /><form runat="server" id="form1"> <input type="file" name="myFile1" /><br/> <input type="file" name="myFile2" /><br/> <input type="file" name="myFile3" /><br/> <ASP:LinkButton runat="server" text="上传" /> <ASP:LinkButton runat="server" text="取消" onClientClick="Cancel(); return false;" /><br/> <br/> <fup:FileUploadProgress OnClientProgressStopped = "function(){alert('文件已上传');}" OnClientProgressStarted = "Clear" OnClientServerException = "ServerException" ShowUploadedFiles = "true" runat = "server" ID = "uploadProgress" InnerFiles = "true" StyleFile = "fup_styles/myStyle.css" LocalizationFile="fup_localization/en.xml" /> <fup:StatusPanel runat="server"> <asp:Label runat="server" id="uploadedFiles" Text="" /> </fup:StatusPanel> <br /></form></body></html>
评论