Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Ajax Uploader
»
Re: Any way to "restart" upload from where it left off?
Re: Any way to "restart" upload from where it left off?
11-08-2009, 8:21 PM
cutechat
Joined on 07-22-2004
Posts 2,332
Re: Any way to "restart" upload from where it left off?
Reply
Quote
Hi,
Here is two samples :
<%@ Page Language="C#" %> <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args) { if (args.FileSize > 10000) throw (new Exception("file should not larger then 10K")); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnFileValidating="UploadAttachments1_FileValidating"> </CuteWebUI:UploadAttachments> </div> <div id="diverrormsg"> </div> </form> <script type="text/javascript"> var uploader=document.getElementById('<%=UploadAttachments1.ClientID %>') var currentfileresumecount=0; var currentfilename; var timesmsg=["first try","second try","third try"]; function CuteWebUI_AjaxUploader_OnStart() { //this event fire at every file begin upload currentfileresumecount=0; } function CuteWebUI_AjaxUploader_OnError(msg) { uploader=this; var diverrormsg=document.getElementById("diverrormsg"); if(currentfileresumecount<3) { uploader.setresumeoption("Resume"); diverrormsg.innerHTML=currentfilename+" ("+timesmsg[currentfileresumecount]+") <hr/>"+msg; currentfileresumecount++; } else { uploader.setresumeoption("Cancel"); diverrormsg.innerHTML=currentfilename+" have been cancelled after 3 times retry <hr/>"+msg; } return false; } function CuteWebUI_AjaxUploader_OnQueueUI(list) { for(var i=0;i<list.length;i++) { if(list[i].Status=="Upload") currentfilename=list[i].FileName; } } </script> </body> </html>
<%@ Page Language="C#" %> <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args) { if (args.FileSize > 10000) throw (new Exception("file should not larger then 10K")); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div id="resumeconfirmdialog" style="display: none; position: absolute; width: 100%; background-color: White; padding: 64px; z-index: 8888"> <div> Get Upload Error : </div> <div style="width: 800px;"> <span id="resumeconfirmlabel" style="display: none;"></span> </div> <div> <button onclick="doresume()"> Resume</button> <button onclick="docancel()"> Cancel</button> </div> </div> <div> <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnFileValidating="UploadAttachments1_FileValidating"> </CuteWebUI:UploadAttachments> </div> </form> <script type="text/javascript"> var uploader=document.getElementById('<%=UploadAttachments1.ClientID %>') function CuteWebUI_AjaxUploader_OnError(msg) { uploader=this; document.getElementById('resumeconfirmdialog').style.display=''; document.getElementById('resumeconfirmlabel').innerHTML=msg; uploader.setresumeoption("Suppend"); return false; } function doresume() { document.getElementById('resumeconfirmdialog').style.display='none'; uploader.setresumeoption("Resume"); } function docancel() { document.getElementById('resumeconfirmdialog').style.display='none'; uploader.setresumeoption("Cancel"); } </script> </body> </html>
Regards,
Terry
View Complete Thread