Jump to content

[SOLVED] Permission denied for unlink() on directory


bassguru

Recommended Posts

Hello everyone

 

I am attempting to delete a folder on my WAMP computer using unlink(). The problem is that I recieve the following error when I run the script:

 

Warning: unlink(...) [function.unlink]: Permission denied in C:\wamp\www\...php

 

Here is the code:

 

	if ($file) {
	$deleteFile = $file;
	unlink("images/display/".$deleteFile);
}

 

I doubt there is a problem with the code.

 

 

How do I sort the permission for the Apache? When the folders are created they are given a permission of 0777 so it should be OK?

 

Perhaps its just Windows =[

 

Many thanks in advance

bassguru

Setting permissions to 0777 has no effect on a windows platform

 

I would say change the files permissions to everyone, and re-try the script, but if you created the file via a php script it should be fine..

 

try rebooting windows then try a simple 1 line script to delete the file, if that works. then I would guess you have one of the following problems

1. the file has been opened and not closed.

2. the $file is empty and PHP is attempting to unlink a folder

3. you have some special permission set to stop the deleting process

Sorry for wasting everyone's time!

 

I was attempting to delete a folder with unlink() (which is a function for file deletion, not folder deletion).

 

I am now using rmdir(), which works perfectly.

 

The only problem is when there are files inside the folder (rmdir cannot delete directories when there are files stored within them) I am deleting, in which case I have a script that deletes all the files inside the folder before it deletes the actual folder itself.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.