Overwrite if file_exists();

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Overwrite if file_exists();

Post by $var »

When uploading a file to a directory where it already exists,
is there a way to overwrite the file with the same name?

I figure as much that it will be with file_exists();

I found an example of how to rename a file, but nothing to really name overtop of a file.
Woud that be a procedure like:

if file exists, delete file then copy file?

or is there a setting to use?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll need to delete the existing file, yes. unlink()
Post Reply