Page 1 of 1

Check file upload selected

Posted: Tue Apr 13, 2010 3:02 pm
by agibsonsw
Hello.
Using a file input type how can I check whether any file was selected?
I've tried 'isset($_FILES['Resume'])' and '$_FILES['Resume']['size']>0' but no joy. Thanks, Andy.

Re: Check file upload selected

Posted: Tue Apr 13, 2010 4:59 pm
by agibsonsw
I've discovered that

Code: Select all

if (empty($_FILES['Resume']['name'])) {
            echo "You haven't selected a file.<br />";
            exit();
}
seems to work, but I'm not sure why the other versions don't. Anyone know why? Thanks, Andy.

Re: Check file upload selected

Posted: Tue Apr 13, 2010 8:15 pm
by requinix
The correct method is to check $_FILES[...][error]: if it ==4 then no file was uploaded.