Welcome Guest, Not a member yet? Register   Sign In
Script is seeing the userfile as not empty, yet it is empty...
#1

[eluser]dallen33[/eluser]
Here's my code, pretty simple.
Code:
if ($this->form_validation->run() == FALSE):
            if (isset($_FILES['userfile']) AND !empty($_FILES['userfile']['name'])):
                if ($_FILES['userfile']['size'] == 0):
                    $data['file_error'] = 'File size is zero.';
                    $this->template->build('booking', $data);
                else:
                    $dir = random_string('alnum', 10);
                    mkdir('/Applications/MAMP/htdocs/extras/uploads/temp/'.$dir);
                    $this->Database_model->attachmentUpload($_FILES, $dir);
                endif;
            else:
                $this->template->build('booking', $data);
            endif;
        else:

Uploads are optional with my script, so I want to check to see if the userfile is filled. if it isn't, it should skip the directory creation step, but it doesn't. It creates the directory with no file, since no file is selected.

Of course, when I print_r the $_FILES['userfile']['name'], I get an array. So it's not empty. Shouldn't it be?

Code:
Array ( [0] => )

What am I missing here? My HTML for the file upload looks like this:

Code:
<input id="userfile1" name="userfile[]" type="file">

The funny thing is... I had this working last week. I took a few days off and now I can't figure out what I did to screw this up. Any help would be appreciated!




Theme © iAndrew 2016 - Forum software by © MyBB