Welcome Guest, Not a member yet? Register   Sign In
Check if input type="file" is set.

Hey all,

I need to check if an input type="file" is set or not. I tried it with
if(!empty($_FILES['userfile'])) {
but that's not working... Is this possible, or do I have add an additional checkbox that needs to be checked if you want to upload the selected file (maybe with some javascript that auto selects it when you click the "browse" button).


edit: lazy me: should've googled better.
if(!empty($_FILES['userfile']['name'])) {
Provides the solution!

a better way is
if($_FILES['userfile']['error'] != 4){}
That is the error nothing is added to the upload field. If the name is an empty string other errors could have occurred.

aha! thanks Wink

Theme © iAndrew 2016 - Forum software by © MyBB