Page 1 of 1

Advanced Image Upload Question

Posted: Wed Jul 14, 2004 10:14 pm
by Mr. Tech
Yo!

I know how to upload a file with php ok.

My only problem is this how do I get the script to check if the file already exists, and then ask if you want to overwrite the file. If you click yes it will overwrite, if you click no it will not upload.

How do I do this?

Posted: Wed Jul 14, 2004 10:41 pm
by feyd
[php_man]file_exists[/php_man] for checking existance. Then write a specialized form to handle the overwrite dialog. The upload would have to have already happened by this point. Instead of moving the file, it'd just [php_man]unlink[/php_man] to delete the temporary file..

Posted: Thu Jul 15, 2004 3:18 am
by Grim...

Code: Select all

<?php
$paste_name = $file_name;
while (file_exists($paste_name))
{
    $paste_name = rand(0, 9).$paste_name;
}
?>