PHP unlink denied on localhost / windows

喜夏-厌秋 提交于 2019-12-25 16:44:52

问题


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

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> ?


回答1:


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



来源:https://stackoverflow.com/questions/22644060/php-unlink-denied-on-localhost-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!