【问题标题】:Dropzone delete uploaded images from serverDropzone 从服务器删除上传的图像
【发布时间】:2014-12-05 15:39:37
【问题描述】:

我使用 dropzone.js 将图像上传到服务器。
现在我希望能够删除 dropzone 中刚刚上传的图像。

我的放置区配置:

Dropzone.options.myAwesomeDropzone = {
   paramName: "file",
   maxFilesize: 10,
   url: '/test',
   maxFiles: 3,
   accept: function (file, done) {
      console.log(file);
      if (file.type !== "image/jpeg" && file.type !== "image/png" && file.type !== "application/pdf") {
        done("Error! Files of this type are not accepted");
      }
      else { done(); }},
   addRemoveLinks: true
};

addRemoveLinks: true 启用缩略图上的删除按钮,但这只会删除拖放区中的缩略图。 实际文件仍在服务器上。

上传代码:

  foreach (string s in Request.Files)
  {
     _file = Request.Files[s];
     var pathToFile = Path.Combine(physicalPathToDirectory, _file.FileName);

     _file.SaveAs(pathToFile);

   }

【问题讨论】:

    标签: c# dropzone.js


    【解决方案1】:

    您需要向您的 dropzone 选项对象添加一个 init 函数,并监听 removedfile 事件。

    init: function() {
        this.on("removedfile", function(file) {
            //add in your code to delete the file from the database here 
        });
    }
    

    这些都在文档中。查找“收听事件”部分以获取更多信息。 http://www.dropzonejs.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-04
      • 1970-01-01
      • 2018-07-11
      • 1970-01-01
      • 1970-01-01
      • 2015-03-20
      • 1970-01-01
      相关资源
      最近更新 更多