How do I delete an old image file and Rename a new image file please?

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
IChaps
New php-forum User
New php-forum User
Posts: 116
Joined: Tue Mar 01, 2016 3:07 pm

Mon Sep 26, 2016 7:34 am

Hello.

Just a quick query.
I've got some php code which will upload a image file to the server. - Which is working.

All I would like to check is, how do I delete the old image file on the server and if I decide to rename a filename, how might I go about it?

I'm currently looking at the following:-
chmod($old_filename,0755);
unlink($old_filename); //Delete the old file
rename($newfile_name, $old_filename); //Rename the new file to the old filename.


Have I got the right code?
Thank You.

AdoptiveSolution
New php-forum User
New php-forum User
Posts: 167
Joined: Wed Jun 15, 2016 8:35 am

Mon Sep 26, 2016 8:14 am

If you have the code, why not use it?

Or do you need confirmation?

Well, here's the confirmation :

http://www.w3schools.com/php/func_filesystem_unlink.asp
http://www.w3schools.com/php/func_filesystem_rename.asp

IChaps
New php-forum User
New php-forum User
Posts: 116
Joined: Tue Mar 01, 2016 3:07 pm

Mon Sep 26, 2016 11:31 am

Hello AdoptiveSolution.

I'd just like confirmation that I'm using the code.
I've attempted to use it, but it dose not do anything.
I was wondering if it is correct, or do I need to insert some kind of ftp as well.

Thanks.

Post Reply