This is a migrated thread and some comments may be shown as answers.

[Solved] Cancel button behaviour

0 Answers 12 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 10 Aug 2012, 03:22 PM
Hi, I'm new to the Telerik upload component.

I'm using VS2010 and MVC 4 with the telerik MVC extenstion suite.
Using the upload compoment configued to use async and multiple files.

I don't understand the functionality of the cancel button that appears after you click Upload Files button.
The button removes all the files from the screen but the upload is not canceled,  the server still receives all the files. I've been testing this with large files (100MB) trying to avoid potential timing issues like the file finishes being sent before I click cancel)

I've read the documentation and the reviewed the demos and it is still not clear to me.

My questions
1) is the cancel button cancelling the upload of ALL remaining files( files that haven't already finished being sent to the server)
2) is the cancel button supposed to only cancel the one file that it is beside?
3) do I need to implement the cancel functionlity? if yes how?
4) why do the files still go to the server after clicking cancel?

Thanks in advance!
Steve


My view code my and controller code is pretty much what you find in the upload demos here.
public class UploadController : Controller
    {
 
        public ActionResult Index()
        {
            return View("MultipleFile");
        }
        public ActionResult UploadResult()
        {
            return View("MultipleFile");
        }
 
        [HttpPost]
        public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
        {
            if (attachments != null)
            {
 
                foreach (var file in attachments)
                {
                    // Some browsers send file names with full path. This needs to be stripped.
                    var fileName = Path.GetFileName(file.FileName);
                    var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
 
 
                    file.SaveAs(physicalPath);
                }
            }
 
            // Return an empty string to signify success
            return Content("");
        }
 
        public ActionResult Remove(string[] fileNames)
        {
            // The parameter of the Remove action must be called "fileNames"
            if (fileNames != null)
            {
                foreach (var fullName in fileNames)
                {
                    var fileName = Path.GetFileName(fullName);
                    var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
 
                    // TODO: Verify user permissions
                    if (System.IO.File.Exists(physicalPath))
                    {
#if DEBUG
                         System.IO.File.Delete(physicalPath);
#endif
                    }
                }
            }
 
            // Return an empty string to signify success
            return Content("");
        }
 
        private IEnumerable<string> GetFileInfo(IEnumerable<HttpPostedFileBase> attachments)
        {
            return
                from a in attachments
                where a != null
                select string.Format("{0} ({1} bytes)", Path.GetFileName(a.FileName), a.ContentLength);
        }
 
    }

Tags
Upload
Asked by
Steve
Top achievements
Rank 1
Share this question
or