0

I'm trying to delete specific file name into a folder depend of the action of the user and I receive this warning:

Warning: unlink(): http does not allow unlinking in

This is the code that have the button that provide the navigation to the deleteRecord.php

> <script>                                                  //btn delete
>         $(".btn_delete").click(function(){
>           var id = $(this).closest('tr').children('td:first').text();
>             //alert(id);                                          
>               var x;
                if (confirm("Are you sure you want delete this record?") == true) {
>                //alert ("You pressed OK!");                                                       
>               
>               location.href='deleteRecord.php?filename='+filename;
>                   } else {
>                       //alert ("You pressed Cancel!");
>                       return false;           }
>         });
>     </script>

This work very good I put it to show to where come the variable id

And now this is the php page that return the Warning:

$filename = $_GET['filename']; //get the filename like "yo.jpg"

$path = "http://www.here I have the exact address to the folder/";

unlink($path . '/' . $filename);

and this is the result I will put it again!

******Warning: unlink(): http does not allow unlinking in******

Any suggestions? Any advice? Please sorry about my english, I'm learning!

2
  • 2
    You can't unlink a URL. You unlink the file on the file system. Commented Jun 2, 2015 at 16:58
  • http://yoursite.com/delete.php?file=/etc/passwd sanitize and validate your inputs. Commented Jun 2, 2015 at 17:05

1 Answer 1

3

You need to pass the server's path to the file as the argument to unlink() rather than the URL, for example:

unlink('/var/www/mywebsite.com/images/myimage.jpg')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.