【问题标题】:Delete script for Dropzone.js and PHP not workingDropzone.js 和 PHP 的删除脚本不起作用
【发布时间】:2013-12-24 11:14:23
【问题描述】:

我正在使用 dropzone 进行文件上传。单击removeLink 时,我想删除服务器上的文件。为此,我使用打开 .php 站点的 Ajax。但不知何故,我无法传递应该删除的文件的文件名(delete_image.php 有效)。如何传递文件名以便将其删除?

 addRemoveLinks: true,
 removedfile: function(file) {
$.ajax({
type: 'POST',
url: 'delete_image.php',
data: {name: +file, dir: "<? echo $_GET['id']; ?>"},
});
 var _ref;
 return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) :       void 0;        
  }

信用:code from this site

【问题讨论】:

    标签: javascript php ajax dropzone.js


    【解决方案1】:

    最简单的方法

    JS文件,当你点击删除按钮时该脚本将运行

    this.on("removedfile", function(file) {
    alert(file.name);
    
    $.ajax({
    url: "uploads/delete.php",
    type: "POST",
    data: { 'name': file.name}
    });
    
    
    });
    

    php 文件“delete.php”

    <?php
    $t= $_POST['name'];
    echo $t;
    unlink($t); 
    ?>
    

    【讨论】:

      猜你喜欢
      • 2015-08-13
      • 2015-09-16
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 2018-10-23
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多