469,366 Members | 2,243 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

Permission problems with unlink()

Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
to unlink I get this: "Warning: unlink(file.txt) [function.unlink]:
Permission denied..." What and how do I change this so it works?
Thanks

Aug 19 '06 #1
6 16099
This could be a permission issue. To unlink a file your webserver must
have the permissions to remove it. Most likely your apache is running
as user 'apache', so the file you are removing must either be owned by
user/group apache, or have permissions to be removed by any user (666 /
777).

Terence

Benjamin wrote:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
to unlink I get this: "Warning: unlink(file.txt) [function.unlink]:
Permission denied..." What and how do I change this so it works?
Thanks
Aug 19 '06 #2
I'm sorry I forgot to mention that I'm running windows.

te************@gmail.com wrote:
This could be a permission issue. To unlink a file your webserver must
have the permissions to remove it. Most likely your apache is running
as user 'apache', so the file you are removing must either be owned by
user/group apache, or have permissions to be removed by any user (666 /
777).

Terence

Benjamin wrote:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
to unlink I get this: "Warning: unlink(file.txt) [function.unlink]:
Permission denied..." What and how do I change this so it works?
Thanks
Aug 19 '06 #3
*** Benjamin escribió/wrote (19 Aug 2006 11:04:15 -0700):
I'm sorry I forgot to mention that I'm running windows.
Then right click on the icon in Windows explorer, select "Properties", find
the "Security" tab and set permissions accordingly.

>This could be a permission issue. To unlink a file your webserver must
have the permissions to remove it. Most likely your apache is running
as user 'apache', so the file you are removing must either be owned by
user/group apache, or have permissions to be removed by any user (666 /
777).

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 22 '06 #4
I figured it out. It was stupid really. I had opened the file with
fopen() without running fclose() before trying to unlink() it. Thanks
for your help though.
Alvaro G. Vicario wrote:
*** Benjamin escribió/wrote (19 Aug 2006 11:04:15 -0700):
I'm sorry I forgot to mention that I'm running windows.

Then right click on the icon in Windows explorer, select "Properties", find
the "Security" tab and set permissions accordingly.

This could be a permission issue. To unlink a file your webserver must
have the permissions to remove it. Most likely your apache is running
as user 'apache', so the file you are removing must either be owned by
user/group apache, or have permissions to be removed by any user (666 /
777).


--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 24 '06 #5
Benjamin wrote:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
to unlink I get this: "Warning: unlink(file.txt) [function.unlink]:
Permission denied..." What and how do I change this so it works?
Thanks
Does this happen on PHP 5.1? It may be a PHP5.2 bug, in which case you
should report it.

We need to see some code first, but my guess is that you do not have
permission to delete that file. What is the file CHMOD'd to? Can you
delete it via the command line?

Also, if you unlink something at script shut down (__destruct() for
example), you will run into problems with permissions, because the
engine is in the processing of shutting down and many streams are killed
-- such as MySQL, and likely the filesystem.

Carl
--
Carl Vondrick
www.YoungCoders.com -- Forum for the younger, next generation programmers.
Sep 29 '06 #6
It was totally my fault.
I had created the file with fopen and failed to call fclose before
trying to delete it. I suppose that fopen had use of the file so I
couldn't alter it.
Carl Vondrick wrote:
Benjamin wrote:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
to unlink I get this: "Warning: unlink(file.txt) [function.unlink]:
Permission denied..." What and how do I change this so it works?
Thanks

Does this happen on PHP 5.1? It may be a PHP5.2 bug, in which case you
should report it.

We need to see some code first, but my guess is that you do not have
permission to delete that file. What is the file CHMOD'd to? Can you
delete it via the command line?

Also, if you unlink something at script shut down (__destruct() for
example), you will run into problems with permissions, because the
engine is in the processing of shutting down and many streams are killed
-- such as MySQL, and likely the filesystem.

Carl
--
Carl Vondrick
www.YoungCoders.com -- Forum for the younger, next generation programmers.
Sep 29 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by www.douglassdavis.com | last post: by
4 posts views Thread by Marcin Zmyslowski | last post: by
7 posts views Thread by Jerome Lyles | last post: by
reply views Thread by neoret | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.