i would like to move the files inside uploads/pension/#SOME_VARIABLE_NUMBER#/#SOME_CONSTANT_NUMBER#/
here is my code:
// move pension statements
// located at uploads/pension/%COMPANY_ID%/%USER_ID%/%HASH%
// so just move the %USER_ID% folder to the new company
$oldPensionDir = "uploads/pension/" . $demo_user[Users::companyID] . "/" . $demo_user[Users::userID] . "/";
$newPensionDir = "uploads/pension/" . $newCompanyID . "/" . $demo_user[Users::userID] . "/";
// see if the user had any files, and if so, move them
if(file_exists($oldPensionDir)) {
// if it doesnt exist, make it
if(!file_exists($newPensionDir))
mkdir($newPensionDir);
// move the folder
rename($oldPensionDir, $newPensionDir);
}
however... when i need to make the directory with the "mkdir" function, i get:
mkdir() [<a href='function.mkdir'>function.mkdir</a>]: No such file or directory
ok, maybe the mkdir won't work, but what about the rename? perhaps that will make the directory if it's not there... nope!
rename(uploads/pension/1001/783/,uploads/pension/1000/783/) [<a href='function.rename'>function.rename</a>]: The system cannot find the path specified. (code: 3)
so, there are two errors. i'm pretty sure if the renaming works, i won't even need the mkdir, but who knows... can anyone tell me why these are errors and how to fix them?
thanks!
EDIT: i've modified the code, and now my only issue is an access problem...
rename(uploads/pension/1000_783/,uploads/pension/1001/783/) [<a href='function.rename'>function.rename</a>]: Access is denied. (code: 5)
below is the new code. basically, i rename it three times (because it has to move through folders, but the final move is what causes the 'access denied' error. the odd part is that even when i delete the new dir and it makes a new one, i set it to have perms 0777!!! whats wrong with this?
// move pension and total reward statements
// located at uploads/pension|total_rewards/%COMPANY_ID%/%USER_ID%/%HASH%
// so just move the %USER_ID% folder to the new company
$oldPensionDir = "uploads/pension/" . $demo_user[Users::companyID] . "/" . $demo_user[Users::userID] . "/";
$tempPensionDir1 = "uploads/pension/" . $demo_user[Users::companyID] . "/" . $demo_user[Users::companyID] . "_" . $demo_user[Users::userID] . "/";
$tempPensionDir2 = "uploads/pension/" . $demo_user[Users::companyID] . "_" . $demo_user[Users::userID] . "/";
$newPensionDir = "uploads/pension/" . $newCompanyID . "/" . $demo_user[Users::userID] . "/";
// see if the user had any files, and if so, move them
if(file_exists($oldPensionDir)) {
// if it doesnt exist, make it
if(!file_exists($newPensionDir))
mkdir($newPensionDir, 0777, true);
// move the folder
// first, move it to the pension directory
rename($oldPensionDir, $tempPensionDir1);
rename($tempPensionDir1, $tempPensionDir2);
// second, move it into the new directory
rename($tempPensionDir2, $newPensionDir);
}