I've been studying the topics at this site and others on ways to count uploaded images; and what I've tried hasn't worked. I have seen this question posed and answered many times and most of the answers are something akin to this:
Code: Select all
$count = count($_FILES['userfile'] ['name']);
echo "the number of photos is ".$count;Code: Select all
<!-- html here to input form data -->
<label></label><input type="hidden" name="MAX_FILE_SIZE" value="500000000" /><br />
<label for="userfile">Upload photo 1</label>
<input type="file" name="userfile1" id="userfile1" /><br />
<label for="userfile">Upload photo 2</label>
<input type="file" name="userfile2" id="userfile2" /><br />
<label for="userfile">Upload photo 3</label>
<input type="file" name="userfile3" id="userfile3" /><br />
<label for="userfile">Upload photo 4</label>
<input type="file" name="userfile4" id="userfile4" /><br />
<label for="userfile">Upload photo 5</label>
<input type="file" name="userfile5" id="userfile5" /><br /><br />
<label></label><input type="submit" name="userfile" value="Send Ad" />
</form>Code: Select all
$num = 1;
$count = 0;
while ($num <=5) {
foreach ($_FILES['userfile'.$num] as $upload){
if ($upload ['error'] != 4){
}
$count ++;
}
$num++;
}
echo "the number of photos is ".$count;Cheers,
Rick