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
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Wed Jul 14, 2004 4:10 am
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jul 14, 2004 4:12 am
uh.. you're renaming a file to a different folder.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Jul 14, 2004 4:12 am
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jul 14, 2004 4:20 am
doesn't make a ton of sense that renaming ascross differing folders works, sorta.. but ok..
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Jul 14, 2004 5:34 am
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
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Wed Jul 14, 2004 6:19 am
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jul 14, 2004 6:56 am
forget it.. "C:\progra~1" is the short name..
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Wed Jul 14, 2004 7:53 am
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
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Sun Jul 18, 2004 4:02 am
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
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sun Jul 18, 2004 4:52 am
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?
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Sun Jul 18, 2004 5:51 am
how do i add path's to the conf?
pelegk2
Forum Regular
Posts: 633 Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:
Post
by pelegk2 » Sun Jul 18, 2004 5:54 am
tried to sdo what u seggested still isnt working:(
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sun Jul 18, 2004 10:16 am
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")