Problem moving files--PLEASE HELP!

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

Post Reply
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

Problem moving files--PLEASE HELP!

Post by andylyon87 »

Can anyone tell me why this doesn't work, it is meant to move a file from one folder to another; in this case it moves a file (listed on a directory) from a "form_data" folder to a "moderated" folder. I have created both folders and have inserted some test txt files, but it keeps saying the file or directory don't exist.

Code: Select all

if($Rename){
for($n = 0;$n < count($Rename); $n++)&#123;
$OldFilename = $Rename&#1111;$n];
$Old = "form_data/$OldFilename";
$New = "moderated/$OldFilename";
if(rename("$Old", "$New"))&#123;
print("<TR><TD colspan=4><CENTER>Your file $Rename&#1111;$n], was successfully moved!</TD></TR>");
&#125;else&#123;
print("<TR><TD colspan=4><CENTER>Your file, $Rename&#1111;$n], could not be moved.</TD></TR>");
&#125;
&#125;
print("<TR><TD colspan=4><center>&nbsp;</TD></TR>");
&#125;
Last edited by andylyon87 on Sat Mar 20, 2004 1:06 pm, edited 1 time in total.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

have you tried using an absolute path?? ie: \path\to\form_data and \path\to\moderated ??
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

Post by andylyon87 »

this seems to be having no effect, could I use the copy function and then use the delete function to delete the original
Post Reply