Jump to content

[SOLVED] rename


cheesycarrion

Recommended Posts

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

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.