473,567 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16754
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1229
by: Nick Zdunic | last post by:
I have this code which throws up an error on my box (Windows Sever 2003 - Enterprise Edition) MsgBox("Message", MsgBoxStyle.Question OrMsgBoxStyle.MsgBoxSetForeground, "Title") I have tried using this code and still it wont work: Dim permSet As New PermissionSet(PermissionState.None) permSet.AddPermission(New...
1
1425
by: www.douglassdavis.com | last post by:
I screwed up the permissions on my database. Basically I revoked all the permissions of the root account on the mysql table. To try to fix this, I went through all of the instructions here: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html running: mysqld-nt.exe --defaults-file="C:\Program Files\MySQL\MySQL Server...
4
2244
by: Marcin Zmyslowski | last post by:
Hello! I have a few tables in MS SQL Server 2000, where I have admin permissions for these tables. I have created a blank database in MS Access 2003, where I linked a table from MS SQL Server 2000. The problems is that I have only read permissions on these tables in MS Access 2003, while I have admin permissions in MS SQL Server 2000. Is it...
7
8074
by: Jerome Lyles | last post by:
I'm trying to build a database. But none of the users I try to use works. I as normal user doesn't work: :~> createdb mydb createdb: could not connect to database template1: FATAL: user "adriel" does not exist I as postgresql user doesn't work: :~> createdb mydb createdb: could not connect to database template1: FATAL: user...
15
1931
by: sflynn | last post by:
I've just created a new program in Visual Studio 2005, Visual Basic. I can publish, install, and run the program just fine as long as the user is a member of the "Domain Admins" group. My problem is when a non-admin using tries to run the program. The program gets hung up on the following line Dim cn As System.Data.SqlClient.SqlConnection...
0
1703
by: neoret | last post by:
Hello. I have developed an application (an office addin).The application works fine with no error messages on my devoping machine (that machine is not connected to any domains). I have problems getting this application to run on a computer where the user is on a domain (as in a big company where you log on to the company domain).
10
2926
Mague
by: Mague | last post by:
Hey, I am using a server of my friends, and i created a directory through php with exec("mkdir $dir") these are now imposible to get into and delete. (well not impsobile, impossible for a kid my age who doesnt no what they have done) It says permission denied i use smartftp and that covers everything i tihnk.has this happened to anyone before...
5
7048
by: sayeo87 | last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got: <%@ page import="java.io.*" %> <HTML> <BODY> <% Runtime rt = Runtime.getRuntime(); Process p = rt.exec("/bin/ls");
0
7688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7590
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8115
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6272
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3648
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.