[SOLVED] copy(): I can't get the paths right!
Posted: Thu Sep 08, 2005 9:07 am
Hi,
I've been trying to move a file from one folder on a web server to another using copy.
If I use chdir() on the folder the image file is in before calling the function I can sucessfully copy the file within the same folder but with a different name:
I can even move it into the next folder up in the hierachy by doing:
But then it gets too complicated... I need to move the file to another folder which is two folders down from the webroot: (htdocs) so I tried "assets/images/newimage.jpg" but the folder could not be found because this path is not relative to the "images" folder chdir is set to.
So then I tried "../../../assets/images/newimage.jpg" which is the three levels up out of one folder to the root and back down two levels into the other. I've tried many combinations but I either get "no such file or directory" or "basedir restriction in effect...."
The example in the manual only copies and renames a file into the same directory as the source so I got no help here. Can I chdir() mid function to send the file to the correct destination?
I've been trying to move a file from one folder on a web server to another using copy.
If I use chdir() on the folder the image file is in before calling the function I can sucessfully copy the file within the same folder but with a different name:
Code: Select all
chdir("images");
//from the webroot this folder is contribute/static/images/
copy("image.jpg", "newimage.jpg");Code: Select all
chdir("images");
copy("image.jpg", "../newimage.jpg");So then I tried "../../../assets/images/newimage.jpg" which is the three levels up out of one folder to the root and back down two levels into the other. I've tried many combinations but I either get "no such file or directory" or "basedir restriction in effect...."
The example in the manual only copies and renames a file into the same directory as the source so I got no help here. Can I chdir() mid function to send the file to the correct destination?