After a migration of my hoster to another server, I see:

warning: unlink(sites/default/files/js/gmap_markers.js) [function.unlink]: Permission denied in /home/myuser/public_html/includes/ on line 435.

 * Delete a file.
 * @param $path A string containing a file path.
 * @return TRUE for success, FALSE for failure.
function file_delete($path) {
  if (is_file($path)) {
    return unlink($path);

line 435 is return unlink($path);

Which file could have a wrong permission?


cog.rusty’s picture

Since you copied the files, you are the owner and they are probably 644, so apache can't write to them. (In the old server apache had created them and was the owner).

- chmod your files directory and its subdirectories to 777, so that apache can write new files (when you upload therm through drupal)
- chmod that file (sites/default/files/js/gmap_markers.js) to 666 so that apache can delete it (because this is what the error is about).

Rosamunda’s picture

In my case, I´ve deleted the subfolder CSS inside FILES. (I suppose this folder has something to do with the caching functions...)
Hope this helps someone..

tsssystems’s picture

I had this problem after moving my site to another server, but the warnings came after doing updates to drupal core. Deleting the css and js folders was the key to stopping the warnings. Thanks, Rosamunda!

jasonabc’s picture

@cog.rusty - thanks bud - this worked for me perfectly ;-)

RoloDMonkey’s picture

No. No! NO!

What you are saying is, "My employee can't get into the bank vault, so I am going to hang a key next to the vault for him."

Defaulting to 777 is an enormous security hole. It allows anyone to read, write and execute files! You should never allow anyone to have execute power inside of sites/default/files. There should never be anything in that folder that is executable, like a PHP file, but if one does get uploaded you don't want anyone, not even apache, to be able to execute it.

Here is what you should do, in order:

If you have the power, make sure that apache is the owner of sites/default/files and set all sub files and sub folders to 644. That will let apache read and write, and all other users will only be allowed to read.

If you can't chown, but you can still chmod and apache is part of the right group set all files and folders from sites/default/files down to 664.

If, for some reason, the files in sites/default/files do not belong to a user or group that apache is a member of and you don't have the power to change that, start looking for another host. In the meantime, you can chmod to 666 but this does mean that other users might find a way to write to that folder and drop in potential security holes.



tagawa’s picture

I agree, leaving it as 777 is not the right way to go.
Instead, answer #1 on this page solved my "permission denied" issue:

suffering drupal’s picture

Isn't there just "THE ONE" place on Drupal where all correct the permission settings are given ("the" checklist!!)????? Why does Drupal have people uselessly loose time, efforts and maybe money on such stupid issues as permissions?

I have bumped into the (ever) permisson problems sooooooooooooooooo many times (after cron, updates, new modules and of course after "rebuild permissions"):
- sites/default/files/imagecache is not writeable by the webserver.
- warning: unlink(sites/default/files/js/gmap_markers.js) [function.unlink]: Permission denied in /includes/
- etc
- etc
- etc

And every time its hours or days trying to figure out who, why and what caused the problem this time. And to judge by the infinite number of posts hundreds of people run into this problem again and again and again.
And then of course there is always the wise-nut that solves it all with chmod 777. Drupal should not allow it's (beloved?) "community" to have these kind of problems, or the need for such irresponsable "solutions".

I started with Drupal in 2007 and then my life got stuck...

pfrenssen’s picture

Setting up the permissions of the files folder in Drupal is explained in the documentation. It can be found in the "Installation Guide". The page is titled "The files directory".

More detailed instructions for advanced users can be found in the article "Securing file permissions and ownership". You might also be interested in other articles in this section (Securing your site).

I can also recommend to read the "Brief introduction to Unix file permissions" if you have trouble understanding permissions.

alexbk66-’s picture

@'suffering drupal', you are talking here about Druplal in general, not only permission issue!

beto_beto’s picture

i have this issue too

warning: unlink(sites/default/files/css/css_003fd5a74db31e9e90d65fb372d42cfc.css) [function.unlink]: Permission denied in C:\inetpub\vhosts\\httpdocs\includes\ on line 482.

warning: unlink(sites/default/files/css/css_005450ffd0615922373bbc275cb82756.css) [function.unlink]: Permission denied in C:\inetpub\vhosts\\httpdocs\includes\ on line 482.

warning: unlink(sites/default/files/css/css_006151e0a33b063831534605c2195011.css) [function.unlink]: Permission denied in C:\inetpub\vhosts\\httpdocs\includes\ on line 482.

warning: unlink(sites/default/files/css/css_00e0ec4d90cbfdb2269481d2ccae8e9b.css) [function.unlink]: Permission denied in C:\inetpub\vhosts\\httpdocs\includes\ on line 482.

warning: unlink(sites/default/files/css/css_00fcaad9f4fdf7d01fada336c002b462.css) [function.unlink]: Permission denied in C:\inetpub\vhosts\\httpdocs\includes\ on line 482.

what should i do ?

Remove the files CSS >> /sites/default/files/css and Js >>/sites/default/files/js ?

is that the solution !!

pfrenssen’s picture

No you should set your permissions correctly on the server, as is explained above.

beto_beto’s picture

this is a server issue i contact theme and they said to me
this is shown for a security reasons !!!