Maq Posted December 4, 2008 Share Posted December 4, 2008 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); } Quote Link to comment https://forums.phpfreaks.com/topic/135546-solved-warning-renametest1oldtest1txt-functionrename-permission-denied/ Share on other sites More sharing options...
Maq Posted December 4, 2008 Author Share Posted December 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135546-solved-warning-renametest1oldtest1txt-functionrename-permission-denied/#findComment-706135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.