Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.