Page 1 of 1

file management

Posted: Fri Jan 13, 2006 3:39 am
by jaylin
Dear Experts,

now i have a problem that is -
it is possible to copy a file (image) from one folder to any folder without any upload? that will be done in the server.

is there any way to do that?

Posted: Fri Jan 13, 2006 3:42 am
by Skittlewidth

Posted: Fri Jan 13, 2006 4:26 am
by jaylin
this works fine if the folder is in the same level.
in my case,
-currentfolder
- a.jpg
-movedfolder
-filefolder
- index.php
- change.php
i have the copy() function in the chage.php which is in the filefolder. i want to copy a.jpg from currentfolder to movedfolder as b.jpg

how can i do that?

Posted: Fri Jan 13, 2006 4:33 am
by Skittlewidth
Put the path to the second folder plus the new filename as the second argument.

this is working

Posted: Fri Jan 13, 2006 4:36 am
by sp2hari

Code: Select all

copy("a.jpg","../movedfolder/b.jpg");
will work

Posted: Fri Jan 13, 2006 4:37 am
by jaylin
i have 3 folders (old, new, file). i want to move a file from old folder to new folder. my php file is in the file folder.
for say, i want to move 1.jpg from old folder to new as file name 2.jpg

can u give me the code? as i m very urgent and i can't fix it myself.

regards,

Posted: Fri Jan 13, 2006 4:39 am
by Skittlewidth
How many ways do we have to explain this? We have given you the code.

Absolute path

Posted: Fri Jan 13, 2006 4:40 am
by sp2hari
hi,
try giving absolute path
if you are working in a linux server
then give this

Code: Select all

copy("/var/www/html/old/a.jpg"."/var/www/html/new/b.jpg");
Else
try using chdir () function to change your current working directory and then copy :)

Posted: Fri Jan 13, 2006 4:45 am
by Skittlewidth
You can also use the $_SERVER['document_root'] to work out the absolute path for your folders. Your folder must have the correct permissions as well.

EDIT
This should help you:
viewtopic.php?t=37902

As you can see I have been in your postition once before :)

Posted: Fri Jan 13, 2006 4:50 am
by jaylin
the pic can't be seen although i found the file through my ftp.

Posted: Fri Jan 13, 2006 5:02 am
by Jenk
use realpath() to translate relative path to absolute (if it exits)