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

[eluser]Bramme[/eluser]
Hey all,

I need to check if an input type="file" is set or not. I tried it with
Code:
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).

Thanks

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

[eluser]xwero[/eluser]
a better way is
Code:
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.
#3

[eluser]Bramme[/eluser]
aha! thanks Wink




Theme © iAndrew 2016 - Forum software by © MyBB