0

I am using dropzone.js in my angularjs and .net application to upload files. dropzone.files has the uploaded files, I have my own custom angularjs method where I take the Base64String from the dropzone.files and send that string to server and convert that string to Image. Its working fine for images but not with other file types like .docx or pdf. I am basically trying to send dropzone.files to my server and have them converted to HttpPostedFileBase. How do I achieve this?

here is my angularjs controller:-

$scope.create = function () {
    MyService.create($scope.viewModel, $scope.dropzone.files, function () {
        alert.success("success");
    });
};

here is my c# controller:-

[HttpPost]
[AuthenticationFilter(Disabled = true)]
public JsonResult Create(string data, string file)
{
    using (MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(file.Remove(0, 23))))
    {
        Image image = Image.FromStream(memoryStream);
        image.Save(Server.MapPath("~/images/im111.jpeg"));
    }
}
Fakhar Ahmad Rasul
  • 1,595
  • 1
  • 19
  • 37
  • dropzone function asks for a url which gets hit after selecting files in dropzone..........and in that case you get all dropzone files in C# – Shubham Mar 29 '19 at 08:01
  • @Shubham yes I know of the default behavior but that is making a call to the server for every file but I would rather make only one call to the server with all the files attached – Fakhar Ahmad Rasul Mar 29 '19 at 10:18

0 Answers0