By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,485 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,485 IT Pros & Developers. It's quick & easy.

Permission problems with unlink()

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
*** 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

P: n/a
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

P: n/a
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

P: n/a
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.