1
votes

I have this line for delete a folder

<button class='elimina' data-elimina='$path/$file'>elimina $path/$file</button>

get the folder path via JQuery

 $(".elimina").click(function(){
     var data = $(this).data('elimina');
     $.post('file.php',data, function(response) {
        // Log the response to the console
        console.log("Response: "+response);
        });
      });

At the last I pass it to my file.php

$archivo = $_POST['data'];

    rmdir($archivo);

But never got pass the var data to my php file .I put an if(isset($_POST['data'])){echo $_POST['data'];} and never saw the path,but I now the path arrive to Jquery script (because also tested).

I haven´t form,only the button,could be it the problem?

1
that code is extraordinarily dangerous. you're allowing ANYONE to delete ANY file server for which they know the path and your webserver userID has the rights to.Marc B
Is only for my work,I hope anybody will try nothing dangerousIni

1 Answers

1
votes

This is wrong:

 $.post('file.php',data, function(response) {
                    ^^^^

You're not sending a key:value pair, you're just sending value. With no key, PHP has nothing to use to produce a $_POST entry

You should have

 $.post('file.php',{data:data}, function(response) {
                    ^-key  ^--value