cheesycarrion Posted November 13, 2007 Share Posted November 13, 2007 I'm trying to make a script to "delete files," by which I mean move them to a deleted files directory that I can later empty. (Don't worry, this isn't the whole file. I assure you it's safe, and only accesable to me and the other site admin.) I then found out that in php there's no move file function, so you have to rename it.. anyway, I get a message: rename(index.php,php_deletefile/index.php) [function.rename]: Permission denied in /home/cheebac8/public_html/console_submit.php on line 26 after that, I tried opening and closing the file before moving it, because I heard that's a good thing to do. $newname = preg_replace("/\//","-",$deletefile); if (file_exists($deletefile)) { $file_handle = fopen($deletefile,"r"); fclose($file_handle); rename($deletefile,"php_deletefile/" . $newname); $message = "file " . $deletefile . " deleted."; } else { $message = "file doesn't exist"; } Link to comment https://forums.phpfreaks.com/topic/77084-solved-rename/ Share on other sites More sharing options...
phpknight Posted November 13, 2007 Share Posted November 13, 2007 Make sure the permissions of the file allow you to rename it through php. People are doing that move file thing all the time on here, so it should not be too tough. You might also check if you are giving the file a name that is already taken in the deleted directory. Link to comment https://forums.phpfreaks.com/topic/77084-solved-rename/#findComment-390510 Share on other sites More sharing options...
cheesycarrion Posted November 15, 2007 Author Share Posted November 15, 2007 Thanks. Link to comment https://forums.phpfreaks.com/topic/77084-solved-rename/#findComment-391967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.