Question

In portuguese language we use an expression to tell what's going on which is:

this is witchcraft

So, I'm trying to unlink an image, and while I'm writing this topic I'm thinking about the possibility of <img src='url'/> means that the image is open (?).

I have an html table with two columns.

#        |     Image
Delete      Image here displayed
Delete      Image here displayed
etc..       etc...

By clicking "Delete", an AJAX function is performed.

$(".delete").on('click', function(){
    var parent = $(this).parent();
    $.ajax({
        url: 'inc/response.php?type=deleteImage',
        data: {id: $(this).attr('id')},
        type: 'POST',
        success: function(data){
            parent.remove();
        }
    });
});

And the code for deleteImage is the following:

$path = "../images/videos/" . $image->get($_REQUEST['id']);

This returns perfectly the path.

unlink($path);

If the path is incorrect the php log returns:

Error on unlink because file or directory does not exists..

, but the message I'm getting is

PHP Warning:

unlink(../images/videos/): Permission denied in C:\xampp\htdocs\newproject\inc\response.php

Since I'm working locally and it's windows, I've set the right administration rights for the folder. Btw, the folder has the following structure:

images 
   > Videos
         > customer_A
         > customer_B
         > customer_C

enter image description here

The Total Control flag is set for EVERY user.

So, what am I doing wrong? Can the problem be because of the image is "open" in the <img src> ?

Was it helpful?

Solution

You are trying to remove ../images/videos/ directory. It seems your $image->get($_REQUEST['id']) returns empty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top