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.

Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.