I have this short script that should create a directory if one does not exists in that path. then check if a file is in the newly created path, if it is then rename the file with the newName but it seems to create a new file regardless. here is the script.
[code=php]$img_name = $campaign_builder->LogoUpload->GetValue();
$campaign_name = $_SESSION[‘campaign_name’];//name of the new dir
$img_newname = $campaign_name . “_” . $campaign_builder->LogoUpload->GetFileName();//new file
global $COMPANY_LOGOS; //path to current directory where i want thenew folder created “/opt/logos/”
$company_logo_dir =$COMPANY_LOGOS;
$dirRoot = $company_logo_dir . $campaign_name;
if(!file_exists($dirRoot)){
//$company_logo_dir= @
$dirRoot= @mkdir($dirRoot);
}else{
$init_File= $dirRoot.’/’.$img_name;//
if(file_exists ($init_File)){//check if the file $img_name is already here
rename($dirRoot . $img_name, $dirRoot . $img_newname);//lets assume the path to logo ends with a slash/
}
else {
fopen($init_Logo, ‘w’);//will this create the file in the new directory
}
}
Also, how do i put the $img_newname in the new dir?
Help please