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
Share on other sites

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.