我启用了删除链接..但它只是从客户端删除了图像预览,它根本没有向我的delete.php文件发布任何内容..
<script type="text/javascript">
if(typeof Dropzone != 'undefined')
{
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#myDropzone", {
url: "upload.php",
maxFileSize: 50,
acceptedFiles: ".pdf",
addRemoveLinks: true,
removedfile: function(file){
var name = file.name;
$.ajax({
type: 'POST',
url: 'delete.php',
data: "id="+name,
dataType: 'html'
});
var _ref;
return(_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
};
}
</script>
</head>
<body>
<form method="POST" enctype="multipart/form-data" action="parser.php" class="dropzone">
这是delete.php文件
<?php
if(isset($_POST['id'])){
$id = $_POST['id'];
$con=new PDO("mysql:host=localhost;dbname=newimg","root","");
$sql =$con->prepare("DELETE FROM dropimage WHERE id='$id'");
$sql->execute();
echo $_POST['id'].' deleted';
}
?>