Jump to content

[SOLVED] Warning: rename(test1.old,test1.txt) [function.rename]: Permission denied


Maq

Recommended Posts

I have a function that is supposed to write/update a file and, if the user clicks on the checkbox ($use), rename the file.  Everything works fine until it invokes the rename method.  I've closed the file handle, changed its mode to 777, tried to delete the file and create one but still gives the same "Permission denied" error.  Any ideas what could be causing this?  Thanks.

 

Error:

Warning: rename(test1.old,test1.txt) [function.rename]: Permission denied in /usr/local/websites/**********/campaign_editor.php on line 84

 

Code:

 

function updateFile($name, $ids_array, $use) {

$myFile = (file_exists($name.".old")) ? $name .".old" : $name .".txt";
$newFile = ($use != "") ? $name.".txt" : $name.".old";
$fh = fopen($myFile, 'w') or die("can't open file");
for($i=0; $i{
if($ids_array[$i] != "") {
	$stringData = "$ids_array[$i]\n";
	fwrite($fh, $stringData);
}
}
fclose($fh);
rename($myFile, $newFile);
}

Sorry for anyone who spent time trying to solve this issue.  I learned that the problem was with the pertaining directory's permissions.  It did not permit me to change the name of the file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.