Check if specific input file is empty

后端 未结 11 566
醉酒成梦
醉酒成梦 2020-11-29 07:23

In my form I have 3 input fields for file upload:





        
相关标签:
11条回答
  • 2020-11-29 07:50

    Method 1

    if($_FILES['cover_image']['name'] == "") {
    // No file was selected for upload, your (re)action goes here
    }
    

    Method 2

    if($_FILES['cover_image']['size'] == 0) {
    // No file was selected for upload, your (re)action goes here
    }
    
    0 讨论(0)
  • 2020-11-29 07:54

    check after the form is posted the following

    $_FILES["cover_image"]["size"]==0
    
    0 讨论(0)
  • 2020-11-29 07:57
    if ($_FILES['cover_image']['size'] == 0 && $_FILES['cover_image']['error'] == 0)
    { 
          // Code comes here
    }
    

    This thing works for me........

    0 讨论(0)
  • 2020-11-29 07:58
    if($_FILES['img_name']['name']!=""){
       echo "File Present";
    }else{
      echo "Empty file";
    }
    
    0 讨论(0)
  • 2020-11-29 08:01
        if (!$_FILES['image']['size'][0] == 0){ //}
    
    0 讨论(0)
提交回复
热议问题