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
}
?>
精彩评论