0

I have this code

<form method="post" id="usrForm" enctype="multipart/form-data">
     <input type="file" multiple accept=".jpg,.jpeg,.gif" name="fl[]"/>
</form>

//Some Other tags and elements
<input type="button" id="formSubmit" onclick="$('#usrForm').submit()"/>

In php, when I echo print_r($_FILES["fl"]) I get empty array like this

Array ( [name] => Array ( [0] => ) [type] => Array ( [0] => ) [tmp_name] => Array ( [0] => ) [error] => Array ( [0] => 4 ) [size] => Array ( [0] => 0 ) ) 

and therefore I cannot upload any images etc. What am I doing wrong? I have been wondering for about 3 hours searching different articles but all in vein.

4
  • your update code works fine for me, please try print_r($_FILES); Commented Feb 10, 2014 at 10:36
  • 1
    What browser are you using, some relatively new browsers (IE9 for example) still don't support multiple files selection Commented Feb 10, 2014 at 10:38
  • Ok I think then it's IE. Lemme Check it Commented Feb 10, 2014 at 10:39
  • No it's not working even in latest Mozilla firefox and chrome as well Commented Feb 10, 2014 at 10:41

1 Answer 1

1

you should define enctype use

<form method="post" id="usrForm" enctype="multipart/form-data">

insted of

<form method="post" id="usrForm">

update

your code works fine

make sure file upload is On, on php.ini

file_uploads = On; 
Sign up to request clarification or add additional context in comments.

4 Comments

SOrry RezSh but I just forgot to mention that but I have added that
I have updated my question plz see i have already added enctype in my real code but still that hungs
so let me check your question again
please check fileupload throw phpinfo() once again, you may edit invalid php.ini file ? your code works fine for me in chrome and firefox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.