2017-09-20 88 views
0

文件鏈接這是我的索引頁Dropzone.js刪除不工作

<link rel="stylesheet" type="text/css" href="style/dropzone.css" /> 
<script type="text/javascript" src="scripts/dropzone.js"></script> 
<script type="text/javascript"> 
if(typeof Dropzone != 'undefined') 
{ 
    Dropzone.autoDiscover = false; 
    var myDropzone = new Dropzone("#myDropzone", { 
     url: "parser.php", 
     maxFileSize: 50, 
     acceptedFiles: ".pdf", 
     addRemoveLinks: true, 
     removedfile: function(file){ 
      var name = file.name; 
      $.ajax({ 
       type: 'POST', 
       url: 'delete.php', 
       data: "name="+name, 
       dataType: 'html' 
      }); 
      var _ref; 
      return(_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; 
     } 
    }; 
    ) 
} 
</script> 

,這是我delete.php頁

<?php 
if(isset($_POST['name'])){ 
    $name= $_POST['name']; 
    $con=new PDO("mysql:host=localhost;dbname=newimg","root",""); 
    $sql =$con->prepare("DELETE FROM attempt010 WHERE name='$name'"); 
    $sql->execute(); 
    echo PDO:errorInfo; 
} 
?> 

它顯示刪除文件和鏈接它在客戶端工作......它正在刪除圖像預覽,但它不在服務器端工作..它根本就沒有進入刪除頁面..

+0

數據: 「ID =」 + ID - >哪裏該id來自?未在您的代碼中聲明 – juvian

+0

更改了代碼... @ juvian –

+0

如果請求正在創建,您是否已在開發控制檯網絡選項卡中檢查過? – juvian

回答

0
<title>Multiple File Upload with Dropzone</title> 
<link rel="stylesheet" type="text/css" href="style/dropzone.css" /> 
<script type="text/javascript" src="scripts/dropzone.js"></script> 
<script type="text/javascript" src="jquery.js"></script> 
</head> 
<body> 
<form method="POST" enctype="multipart/form-data" action="parser.php" class="dropzone" id="myDropzone"> 
<script type="text/javascript"> 
    if(typeof Dropzone != 'undefined') 
    { 
     Dropzone.autoDiscover = false; 
     var myDropzone = new Dropzone("#myDropzone", { 
      url: "parser.php", 
      maxFileSize: 50, 
      acceptedFiles: ".jpg", 
      addRemoveLinks: true, 
      removedfile: function(file){ 
       var name = file.name; 
       $.ajax({ 
        type: 'POST', 
        url: 'delete.php', 
        data: "name="+name, 
        dataType: 'html' 
       }); 
       var _ref; 
       return(_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; 
      } 
     }); 

    } 
    </script> 

,這是delete.php

<?php 
if(isset($_POST['name'])){ 
    $name = $_POST['name']; 
    $con=new PDO("mysql:host=localhost;dbname=newimg","root",""); 
    $sql =$con->prepare("DELETE FROM attempt010 WHERE name='$name'"); 
    $sql->execute(); 
} 
?>