Sunday, August 27, 2017

Check if file / image attach in html form php

I need to make sure that a file attached through the file input element. I tried various things, including this
if(count($_FILES) > 0)
if(empty($_FILES['filename']))
if(empty($_FILES['filename']['name']))
but all those option was not working for me.

is_uploaded_file(). is worked but it's show error when attach multiple file. name='files[]' because it is not support array. 

Finally the best solution is used for me 
if($_FILES["filename"]['name'][0] != ''){
    //echo 'file attached';
}else{
    //echo 'no file attached';
}

Total Pageviews