Jump to content

[Resolved] Uploading images - blank already uploaded?


BarneyJoe

Recommended Posts

Just as I thought everything was looking just as it should with my add record / upload image page with all it's validation, I've just spotted an odd one - nothing crucial, just a bit odd looking.

I basically have this code to check if a file has already been uploaded :

[code]if (file_exists("Photos/" . $_FILES["uploadFile"]["name"]))
{
  $ValidationFailed = true;
  $FTGvalid_file_errmsg = "This file has already been uploaded. If you are sure it's a new photo please rename it before uploading to the library.";
  $ErrorList .= $FTGvalid_file_errmsg . '<br/>';
    } [/code]

Which works just as it should if a file already uploaded is selected.

However, if no file is selected, I'm still getting the error message.

This isn't major, as a file does have to be uploaded - indeed there is also a check on file type, which flags any blanks anyway - but it's just a bit odd that the 'File is already uploaded' is coming up when no file is selected?

Can this be tweaked at all? I also tried changing the Null column back in mySQL to see if that was an issue, but it didn't seem to be.

Cheers.

Turns out I needed to change :

[code]if (file_exists("Photos/" . $_FILES["uploadFile"]["name"]))[/code]

to :

[code]if (!empty($_FILES['uploadFile']['name']) && file_exists("Photos/" . $_FILES["uploadFile"]["name"]) && is_file('Photos/' . $_FILES['uploadFile']['name']))[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.