title: Kendo Upload to Folder and URL to method in WCF Service
body: <p>Using Kendo Upload, I need to be able to send an attachment on upload to a folder location as well as post to a URL with extra parameters to send the files to a C# web method in a web service where I then perform the code that saves the files to the server.</p>
  
  <p>The upload widget is being used on a create in a Kendo Grid. I am also going to need to find an id that is created server side to use as a parameter in the ashx handler and the wcf method url for the upload. Right now I am hard coding the id. </p>
  
  <p>Code below:  </p>
  
  <pre><code>                 $('#files').kendoUpload({
                  async: {
                      autoUpload: false,
                      saveUrl: "save"
                  },
                  multiple: true,
                  complete: function onComplete(e) {
                      $.map(e.files, function (file) {
                          var info = file.name;
                          e.sender.options.async.saveUrl = attachURL + "&amp;changeControlRequestID=" + 148 + "&amp;changeControlRequestPendingID=" + pendingId + "&amp;directoryName=\\sat1mvdwb022.NAOTEST.G.LAB.GMACFS.COM\BSMShare\BSM\ChangeControl" + "&amp;fileName=" + info;
                      });
                  },
                  upload: function onUpload(e) {
                      $.map(e.files, function (file) {
                          var info = file.name;
                          e.sender.options.async.saveUrl = "ChangeControlHandler.ashx?upload=true";
                      });
                  }                     
              });
  </code></pre>
  
  <p>The first async saveUrl is linked to an ashx file. Code below :</p>
  
  <pre><code>public class ChangeControlHandler : IHttpHandler {
  
   public void ProcessRequest (HttpContext context) {
  
      int ccrID = 146;
      if (context.Request.Files.Count &gt; 0)
      {
          HttpFileCollection fileCollection = context.Request.Files;
          if (fileCollection.Count &gt; 0)
          {
              HttpPostedFile filePath = fileCollection[0];
  
              string savepath = "filepath";
              string name = filePath.FileName.Remove(filePath.FileName.LastIndexOf("."));
              string fileName = ccrID.ToString() + "_" + name.Remove(0, name.LastIndexOf(@"\") + 1)
                     + "_" + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString();
              string fileExt = fileName.Remove(0, fileName.LastIndexOf("."));
              if (!Directory.Exists(savepath))
                  Directory.CreateDirectory(savepath);
              filePath.SaveAs(savepath + fileName + fileExt);
              context.Response.StatusCode = (int)HttpStatusCode.OK;
          }
      }
  
      context.Response.ContentType = "text/plain";
      context.Response.Write("Hello World");
  }
  
   public bool IsReusable {
      get {
          return false;
      }
   }
  
  }
  </code></pre>
  
  <p>The file is being uploaded to the folder but it breaks with this error causing the upload to fail. <a href="https://i.stack.imgur.com/oQm5E.png" rel="nofollow noreferrer">Jquery error</a></p>