1

I am using the DropzoneJS library to upload files. The controler save it directly on the server (inspired by DropzoneJS with ASP.net MVC 5 Tutorial)

It works but I don't get how to call the controler on the DropzoneJS's event removedfile. Here is my code :

Script :

<script>
    Dropzone.options.dropzone = {
        addRemoveLinks:     true,
        dictDefaultMessage: "Drop here",
        dictRemoveFile:     "Delete"
    }
</script>

csHtml :

@using (Html.BeginForm("UploadFile", "Form", FormMethod.Post, new { @id = "dropzone", @class = "dropzone" }))
{
    <div class="fallback">
        <input name="file" type="file" multiple />
    </div>
}

Controler :

public ActionResult UploadFile()
{
    foreach (string requestFile in Request.Files)
    {
        HttpPostedFileBase file = Request.Files[requestFile];
        // Save on server
    }

    return Json(new { response = "File uploaded." });
}

How can I call a new controler like UploadFile() to remove my files ?

C. Chen
  • 123
  • 1
  • 2
  • 9

1 Answers1

1

See DropzoneJS is a ux framework, it only allows the user to interact with their scenario at the moment, you cannot call a method to upload files to delete them.

If you recover the files you uploaded, you must control the deletion with another controller action and search for the file by a id or uid belonging to the image in cuestion, any identifier to remove it from your local.

You may want to look to the second answer in this question.

**since I can't write comments, I'm posting it as an answer.

Dropzone.js- How to delete files from server?enter link description here

Danielle Lpz
  • 312
  • 3
  • 14