Unable to copy/rename files...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
misery29
Forum Newbie
Posts: 1
Joined: Wed Mar 02, 2005 8:09 am

Unable to copy/rename files...

Post by misery29 »

Although all permissions are set correctly (to 0777)...I still cannot copy files from source location to destination via copy() or rename() function:
however, i CAN rename files in the same directory...

is there any limitation in length of a pathname?
should I use relative or absolute paths ? (i guess that it doesnt work with paths like "../../dirA/dirB/" etc.)

I use the following structure:

Code: Select all

$source = '/httpd/html/dir1/dir2/dir3/upload/picture.jpg';
  $dest  = '/httpd/html/dirA/dirB/dirC/dirD/client/picture.jpg';
  if (copy($source, $dest)) {....}
  else { ... show error message ....}
i always get error message...
could someone help me,please?
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

This is not a hard fast rules, just an observation.

I had the same problem on my server but it wasn't as obvious as permissions. It turned out to be a security mechanism in Linux that prevented me from accessing files outside of the web directory. I cannot tell from you have said that this is your problem, but it is something to consider.

I have also had problems related to user/group rights in Linux when it comes to creating/writing to files. You may want to see what user/group PHP is using to do its file access. Generally write type methods are most affected by this behavior.

In another case I found that if a file already existed, PHP could write to it but it could not create the file. Again it was related to user/group itself as in chown related not chmod.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

You could try using the system() command to see whether it works when going direct to the filesystem. If it does, then I imagine that there is a PHP ini setting that needs looking at, or a PHP limitation, as you suggest. If not, it's likely to be a filesystem/permissions/OS issue.

Just a thought.
Post Reply