Hi All,
Im building a CMS where 3 images need to be uploaded. I’m trying to validate by checking for 2 things (at least for now). One, that it’s not empty and
Two, the image must be a .gif
3 images in an upload means a 2 dimensional array. I’ve accessed via 2 foreach loops but am trying to figure out the syntax isolate and check the individaul key => value pairs.
echoing the 2 foreach loops produces this…
Array
(
[add_acchdr_off] => Array (
[name] => accodion_header_off.gif
[type] => image/gif
[tmp_name] => /Applications/XAMPP/xamppfiles/temp/phpGR9rW9
[error] => 0
[size] => 420681
)
[add_acchdr_on] => Array (
[name] => accodion_header_on.gif
[type] => image/png
[tmp_name] => /Applications/XAMPP/xamppfiles/temp/php1B91mn
[error] => 0
[size] => 200434
)
[add_main_pic] => Array (
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
i want to access the [error] and test if it’s 4 (means it’s empty), and also the [type] to see if it’s a .gif or not. how can i do that?
any help would be great, thanks!
my code so far is this,
$imgArr = array($add_acchdr_off, $add_acchdr_on, $add_main_pic);
foreach ($imgArr as $Img) {
foreach($Img as $key => $val) {
echo $key . ‘ ‘ . $val;
//put some val code here
}
}