I've got an upload form which works. However, it will overwrite an existing file if the name is a duplicate. I wanted to do a check for the file, and if the name is already used, send them back to choose a different name. However, the code doesn't seem to work. All upload attempts work and existing files are overwritten. Here's the relevant code.
if (file_exists("documents/$filename.$filetype")) {
printf("Filename already exists. Please click Back and choose a different filename.");
} else {
copy($file,"documents/$filename.$filetype");
odbc_exec($db, "INSERT INTO content (posting_date, content_author, content_email, content_title, content_file, content_body) VALUES ('$date', '$author', '$email', '$title', '$filename.$filetype', '$comment')");
}
What's wrong?