开发者

how to validate an image array in php

开发者 https://www.devze.com 2023-01-07 16:17 出处:网络
<input name= \"p_image[]\" type=\"file\" id=\"p_image[]\"> i need that user upload atleast one image and if it doesn开发者_StackOverflow\'t it show error..You can check the count of the array,
<input name= "p_image[]" type="file" id="p_image[]">

i need that user upload atleast one image and if it doesn开发者_StackOverflow't it show error..


You can check the count of the array, and if it's equal to 0, then throw an error:

<?php

   if(isset($_POST['p_image'])) { 
      if(!(count($_POST['p_image']))) {
          //throw error here...
      }
   } else {
     //throw another error here...
   }
?>


<?php

   if(!isset($_POST['p_image'])) { 

          //failure messgae

   }
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消