Allow overwrite with PHP Pear HTTP_Upload

I am using the PEAR HTTP_Upload to upload images to a file. I want to be able to allow overwriting an existing file. Is there a way to do that?
$upload = new HTTP_Upload('en'); // Language for error messages
$file = $upload->getFiles("brand_logo[$i]"); // return a file object or error
if (PEAR::isError($file)) { die ($file->getMessage());}// Check if the file is a valid upload
$properties = $file->getProp();
$extension = $file->getProp('ext');
if ($file->isValid()) { // this method will return the name of the file you moved, // useful for example to save the name in a database
$file_name = $file->moveTo($abpath);
if (PEAR::isError($file_name)) {  $file_name->getMessage(); $errorFlag=1; }}

Open in new window

Who is Participating?
try to delete file if file exist

if (file_exists($file_name)) {

birwinAuthor Commented:
that worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.