title: PHP jquery ajax unlink images from folder not working
body: <p>I am trying to show and delete images that are stored in folders, but I can not run the JS code that removes each.</p>
  
  <p><strong>My code php in the index.php:</strong></p>
  
  <pre><code>// folder with files    
  $pathimages = $_SERVER['DOCUMENT_ROOT'];
  $pathimages .= "/uploads/files/";
  
  // showing images
  foreach(glob($pathimages.'*') as $filename){
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      $name_only = basename($filename, ".".$ext);
  
      echo "&lt;img src=\"../uploads/files/" .$name_only.".".$ext. "\" width=\"30\" /&gt;
          &lt;a onclick=\"DeleteImage(".$name_only.",".$ext."); return false;\" href=\"javascript:;\"&gt;X&lt;/a&gt;
          &lt;br /&gt;";
  }
  </code></pre>
  
  <p>(Im sending the file-name and extension in two vars, I dont know why)</p>
  
  <p>When I click on the "X", call the function "DeleteImage", but doesnt work.</p>
  
  <p><strong>JS function from .js file imported:</strong></p>
  
  <pre><code> function DeleteImage(name_only, ext){
      var parametros = {
          "name_only" : name_only,
          "ext" : ext
      };
  
      $.ajax({
          url: 'views/delete_image.php',
          type: "POST",
          data: parametros,
          success: function(datos){
              console.log("check");
          }
      });
  }
  </code></pre>
  
  <p><strong>And the delete file php:</strong></p>
  
  <pre><code>$name_only = $_POST['name_only'];
  $ext = $_POST['ext'];
  
  $pathimages = $_SERVER['DOCUMENT_ROOT'];
  $pathimages .= "/uploads/files/";
  
  unlink($pathimages . $name_only .".". $ext);
  echo "Deleted";
  </code></pre>
  
  <p>I have something similar but with records in the database and works OK, using GET method, deleting, editing, etc. But here the problems started. Thank you very much and I apologize for my english.</p>