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

[Solved] Telerik FileUpload doesnot working

3 Answers 78 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.
ujwala
Top achievements
Rank 1
ujwala asked on 30 May 2012, 04:00 AM
Hi,

I am using telerik upload control to upload a csv file.But when i am trying to upload a file it doesnot upload any files also is not going through my controller action.

Below is the code snippet i am using for my View and the controller.
Please let me know if i am missing anything.

View:

@(Html.Telerik().Upload()
            .Name("Loans")
            .Async(async => async
             .Save("SaveFile", "LockLoans")
              )
           .ClientEvents(events => events.OnUpload("onUpload").OnSuccess("onSuccess").OnRemove("onRemove"))
            )

Controller:

[HttpPost]
       public ActionResult SaveFile(IEnumerable<HttpPostedFileBase> attachments)
      {
          req = new RequestService.Service1Client();
          Byte[] fileData = null;
          foreach (var file in attachments)
          {
              using (var binaryReader = new System.IO.BinaryReader(Request.Files[0].InputStream))
              {
                  fileData = binaryReader.ReadBytes(Request.Files[0].ContentLength);
              }
              //save files into database
              req.ExecuteAction(129, currentUserID, Carma.Library.Models.Environment.Source, "SaveFile",
                  new UploadFile
                  {
                      Contents = fileData,
                      FileName = file.FileName.Substring(file.FileName.LastIndexOf("\\") + 1),
                      DateTime = DateTime.Now.ToString()
                  }, null);
              
          }
          return Json(new { status = "OK" }, "text/plain");
      }

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 31 May 2012, 08:19 AM
Hi Ujwala,

I am not sure what exactly might be causing the issue. I created a Upload demo project could you please check it and see if I missed something? If i did modify it and send it back so I can investigate the issue.

Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
ujwala
Top achievements
Rank 1
answered on 31 May 2012, 10:07 PM
Hi,

We have the upload control inside the telerik window.It seems to be working if the upload control is outside of the window.
We have recently upgraded our telerik version to 2012.1.214 and it stopped working since then.
From what we noticed,it creates an initialization script below if the upload control is outside of the telerik window,but it doesnot create it when the control is inside the telerik window.

jQuery(document).ready(function(){

jQuery('#attachments').tUpload({async:{"saveUrl":"/Carma/RequestMgr/Request/LockLoans.mvc/Save","removeUrl":"/Carma/RequestMgr/Request/LockLoans.mvc/Remove","autoUpload":true}});

 

Please let me know if you need more information.
0
Petur Subev
Telerik team
answered on 01 Jun 2012, 11:11 AM
Hi Ujwala,

Could you please replicate the scenario in a sample project (you can use the one from the previous replay) and send it so we can check the exact setup and investigate further what might be causing the issue?

All the best,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Upload
Asked by
ujwala
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
ujwala
Top achievements
Rank 1
Share this question
or