473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why can't PHP chmod a file that is already 777?

I've a simple script to transfer some files from one domain to
another, with both domains living on the same server. The files in
both directories are already chmod 777. Yet after transfer, I try to
ensure that the file is 777, and I get an error. Why?
for ($i=0; $i < count($transfer Array); $i++) {
$fileName = $transferArray[$i];
$commandAsStrin g = "\cp -f /var/www/vhosts/mydomain.com/httpdocs/
site_specific_f iles/$fileName /var/www/vhosts/theice.org/httpdocs/
site_specific_f iles/$fileName";
exec($commandAs String);
chmod("/var/www/vhosts/ice.org/httpdocs/site_specific_f iles/
$fileName", 0777);
if ($i 0) $resultString .= ", ";
$resultString .= "$fileName" ;
}
The files copy over just fine, but the line where I try to do chmod, I
get this error:

"Warning: chmod(): Operation not permitted in /var/www/vhosts/
cyberbitten.com/httpdocs/sharedCode/
transferFilesFr omCyberbittenTo TSR.php on line 33"

The owner and the group of the file change to "www-data" which is
annoying, but which should allow PHP to do anything it wants with the
files. So why would I get an error?

I also tried to end with this line:

exec("chown mgtr /var/www/vhosts/ice.org/httpdocs/site_specific_f iles/
$fileName");

This doesn't work at all. Why?

I ssh to the server and edited the configuration files to be sure the
open_basedir restriction was off, then I rebooted Apache. That made
no difference, for this particular bug.




Jun 2 '08 #1
1 3201
lawrence k wrote:
I've a simple script to transfer some files from one domain to
another, with both domains living on the same server. The files in
both directories are already chmod 777. Yet after transfer, I try to
ensure that the file is 777, and I get an error. Why?
for ($i=0; $i < count($transfer Array); $i++) {
$fileName = $transferArray[$i];
$commandAsStrin g = "\cp -f /var/www/vhosts/mydomain.com/httpdocs/
site_specific_f iles/$fileName /var/www/vhosts/theice.org/httpdocs/
site_specific_f iles/$fileName";
exec($commandAs String);
chmod("/var/www/vhosts/ice.org/httpdocs/site_specific_f iles/
$fileName", 0777);
if ($i 0) $resultString .= ", ";
$resultString .= "$fileName" ;
}
The files copy over just fine, but the line where I try to do chmod, I
get this error:

"Warning: chmod(): Operation not permitted in /var/www/vhosts/
cyberbitten.com/httpdocs/sharedCode/
transferFilesFr omCyberbittenTo TSR.php on line 33"

The owner and the group of the file change to "www-data" which is
annoying, but which should allow PHP to do anything it wants with the
files. So why would I get an error?

I also tried to end with this line:

exec("chown mgtr /var/www/vhosts/ice.org/httpdocs/site_specific_f iles/
$fileName");

This doesn't work at all. Why?

I ssh to the server and edited the configuration files to be sure the
open_basedir restriction was off, then I rebooted Apache. That made
no difference, for this particular bug.
I haven't seen your entire command, but cp could be failing here. a+x on
the destination directory.. chown won't change the owner unless the
person running it is root or through sudo.
Jun 2 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1289
by: Pola | last post by:
I am using VC++ in my application I create file every second and save on the disk at the same time another appl reads this file every second from the disk How I can know that file is in use. thank yo
0
1091
by: Chris Hartnell | last post by:
I have a database, a front end, that links to another datafile which is also an mdb. I have run into problems with error messages that say 'File Already in Use', when both files reside only on my computer and are not already in use. Any idea of how I can fix this? I am using Access 2003. I have had similar DB setups with previous versions of Access and have had no problems. Thanks,
1
1851
by: samotek | last post by:
I am trying to unzip files zipped with inzip9 and after that to open a database Survey. I get the message Couldnt use file "C:BE\survey. File already in use". and the database is not opened.I ca open the database if i run only the SgellExecute line. But i wan tto run the three lines together.How can i avoid this sticking of the function?
6
13721
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the error (seems to be happening when I try creating a directory) If dirmgr.Exists("s:\blah\" & txt_name.Text) Then lblerror.Text = lblerror.Text & "Unable to build physical path. " &
1
1009
by: davidw | last post by:
I found I can access static file in my IIS folder that have ~ in their file name, but I have no way to let httphandler to handle such request, for example, http://mydomain/test.aspx returns 401, but http://mydomain/test~.aspx returns File names for monitoring must have absolute paths, and no wildcards. could anyone tell me why it acts like that?
4
9465
by: Miro | last post by:
I've read a couple of threads on this error but none of them could help me so I'm posting myself. When I try open and read (not update) an ACCESS database on a network share I occasionally get: "Could not use ''; file already in use." error. This always happens when the database is open but sometimes even when it's not. Not manually anyway. I consequently use DataAdapter.Fill() method which
3
3765
by: webhead | last post by:
I have a web where users can upload photos, but they want to also be able to delete them. The directory can have chmod changes but it won't let me chmod the files and unlink them. I'm assuming it really is a chmod problem even though the error message is "no such file or directory", as I'm sure the name and path are right. Even my ftp program won't let me chmod the files, is this a safemode problem?
5
6531
by: rn5a | last post by:
I am using the following connection to connect to a MS-Access database: --------------------------------- set con = server.createObject("adodb.connection") path1 = server.mappath("./db/MyDB.mdb") con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& path1 &";Persist Security Info=False"
1
1310
by: bindiyadsouza | last post by:
hey i am using asp coding and access is my db. i am just inserting values in to the table and trying to view it. every thing works fine locally but when i upload it it gives Microsoft JET Database Engine error '80004005' Could not use ''; file already in use. /asp/viewRecruiters1.asp, line 239 error online.. in that line 239
2
5025
by: Mourad | last post by:
I'm getting this message when starting application A (Access 2003), while Application B (Access 2.0) is running. ABC.mdb is a back-end Access database (2.0) that has shared tables with links in both applications A and B. This problem does not exist when application A (2003) is started first (before application B (2.0)! It seems that A2003 cannot read .ldb file created by A2.0, however A2.0 can read .ldb file created by A2003!
0
8675
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
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
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.