best way to rename a file after processing it

Hi,

I’m using file_get_contents to read a file and inset the contents line by line into a db. Then i want to rename the file afterwards. I wondered what would be the recommended (or safest!) way to rename the file that i just processed?

thanks,

Well, just use the rename function, that is what it’s there for.

$dirname=“somefilename…”;
$newname=“newfilename.txt”;
rename($dirname , $newname);

You could COPY it to another folder for a backup and then rename it there.
It depends on what you want to keep the file for and how many you keep.

Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service