Page 1 of 1
rename() erro
Posted: Wed Jul 14, 2004 4:10 am
by pelegk2
i have tried to rename a filelike this:
Code: Select all
rename("files/0421045_01.txt","files/backup/0421045_01.txt")
and it didnt work(and i have permmisions for these folder)
the fles folder is a flder in the folder where my scripts run's
and the backup folder is inside the files folder!
when i also try
Code: Select all
rename("/files/0421045_01.txt","/files/backup/0421045_01.txt")
i still get the medssage
no such file or directory!
what to do?
thanks in advance
peleg
Posted: Wed Jul 14, 2004 4:12 am
by feyd
uh.. you're renaming a file to a different folder.

Posted: Wed Jul 14, 2004 4:12 am
by JayBird
try this
Code: Select all
rename($_SERVER['DOCUMENT_ROOT']."/files/0421045_01.txt",$_SERVER['DOCUMENT_ROOT']."/files/backup/0421045_01.txt")
does the backup folder exist?
Mark
Posted: Wed Jul 14, 2004 4:20 am
by feyd
doesn't make a ton of sense that renaming ascross differing folders works, sorta.. but ok..
Posted: Wed Jul 14, 2004 5:34 am
by JayBird
feyd wrote:doesn't make a ton of sense that renaming ascross differing folders works, sorta.. but ok..
Well, the isn't a move funtion, so this is an alternative
Posted: Wed Jul 14, 2004 6:19 am
by pelegk2
Bech100 2 things :
first your code is ok
second how do i get the shortname of : "C:\Program Files"
third : yes its alternative for the move function:)
and feyd what there isnt a sence in it?
Posted: Wed Jul 14, 2004 6:56 am
by feyd
forget it.. "C:\progra~1" is the short name..
Posted: Wed Jul 14, 2004 7:53 am
by pelegk2
feyd : forget it????????????????????????????????/
why is that?>
i know that the sort name
but there are cases like other folder that it will not always be ****~1
still isnt working
Posted: Sun Jul 18, 2004 4:02 am
by pelegk2
Bech100
when i treid to do :
Code: Select all
$_SERVERї'DOCUMENT_ROOT']."/files/0421045_01.txt",
i got :
Code: Select all
"C:\\\\Program Files\\\\nusphere\\\\phpED\\\\/files/0421061_02.txt"
and when i tried to write manually the path to the file like this :
Code: Select all
rename("C:\\Program Files\\Apache Group\\Apache2\\htdocs\\uniprod\\files/0421061_02.txt","C:\\Program Files\\Apache Group\\Apache2\\htdocs\\uniprod\\files\\backup\\0421061_02.txt")
i still get the error :
that permmision denied! :
Warning: rename(C:\Progra~1\Apache~1\Apache2\htdocs\uniprod\files/0421061_02.txt,C:\Progra~1\Apache~1\Apache2\htdocs\uniprod\files\backup\0421061_02.txt): Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\uniprod\readFiles.php on line 30
OR
Warning: rename(C:\Program Files\Apache Group\Apache2\htdocs\uniprod\files/0421061_02.txt,C:\Program Files\Apache Group\Apache2\htdocs\uniprod\files\backup\0421061_02.txt): Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\uniprod\readFiles.php on line 29
what to do?
thanks in advance
peleg
Posted: Sun Jul 18, 2004 4:52 am
by JAM
It has to do with Apache's permissions. You are (likely) only allowed to use paths stored in the conf.
The following might work. Note the single dot:
Code: Select all
rename("./foo.bar", "./backup/bar.foo");
./ means "current dir", so in other words, my index.php containing the above line is in the same directory as the foo.bar file. Might be of use?
Posted: Sun Jul 18, 2004 5:51 am
by pelegk2
how do i add path's to the conf?
Posted: Sun Jul 18, 2004 5:54 am
by pelegk2
tried to sdo what u seggested still isnt working:(
Posted: Sun Jul 18, 2004 10:16 am
by JAM
You have the following structure of directories:
"/uniprod/readFiles.php"
Meaning, you are in the uniprod directory when calling the script. We call this directory '.'
You have a file you want to move in a sub-directoty called files. Slap those together and we have:
"./Files/"
So perhaps you want:
Code: Select all
rename("./files/0421045_01.txt","./files/backup/0421045_01.txt")