开发者

how to validate an image array in php

<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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜