Page 1 of 1

Unable to copy/rename files...

Posted: Wed Mar 02, 2005 8:24 am
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?

Posted: Wed Mar 02, 2005 8:38 am
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.

Posted: Wed Mar 02, 2005 8:59 am
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.