473,413 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

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($transferArray); $i++) {
$fileName = $transferArray[$i];
$commandAsString = "\cp -f /var/www/vhosts/mydomain.com/httpdocs/
site_specific_files/$fileName /var/www/vhosts/theice.org/httpdocs/
site_specific_files/$fileName";
exec($commandAsString);
chmod("/var/www/vhosts/ice.org/httpdocs/site_specific_files/
$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/
transferFilesFromCyberbittenToTSR.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_files/
$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 3182
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($transferArray); $i++) {
$fileName = $transferArray[$i];
$commandAsString = "\cp -f /var/www/vhosts/mydomain.com/httpdocs/
site_specific_files/$fileName /var/www/vhosts/theice.org/httpdocs/
site_specific_files/$fileName";
exec($commandAsString);
chmod("/var/www/vhosts/ice.org/httpdocs/site_specific_files/
$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/
transferFilesFromCyberbittenToTSR.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_files/
$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
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. ...
0
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...
1
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...
6
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...
1
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,...
4
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:...
3
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...
5
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 = ...
1
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...
2
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.