file exists problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Hello again.
I use this file-upload example below. But I want to check if a file
exists. I have tried to put the file_exists() function inside of this.
But it did not work well..

(The example below is taken from Oreillys PHP Cookbook and it work
nice. But it overwrite existing files and I like to receive an error
and protect files on the server from this.)

Thanks for all advice.


// *** Nyhets Bilde ***
if (isset($_FILES['nyhets_bilde']) &&
    ($_FILES['nyhets_bilde']['error'] == UPLOAD_ERR_OK)) {
        $bildesti = '../nyheter/' . basename($_FILES['nyhets_bilde']
        } else {
        $bildenavn = basename($_FILES['nyhets_bilde']['name']);
$bildesti)) {
            } else {
                   $nyhets_bilde = "$bildenavn";
        } else {
            $nyhets_bilde = "Kunne ikke flytte bilde til $bildesti";
    } else {
       $nyhets_bilde = "";

Site Timeline