It’s doing what I want it to do. I’ll comment it out.
[php]
DEFINE(“NUM_OF_ALLOWED_IMAGES”, 6); // This is the maximum number of allowed images
$imgCount = 0; // Initialize the count of images to zero
for($i = 0; $i < NUM_OF_ALLOWED_IMAGES; $i++){ // Run the loop to check for image ( 6 times for this case)
if($_FILES['image']['size'][$i] > 0){
$imgCount++; // If the size of that image is greater than zero than an image is being uploaded so we add on to the image count
}
}
[/php]
So if 2 images were being uploaded than the $imgCount would be “2”.
The downside to doing this is the script doesn’t know which inputs they used for the uploads.
Example…
Say you have six allowed files to upload,
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
Now the user decides to upload only two images, but doesn’t start from the first input…
<input type='file' name='image[]'/> <!-- They leave this one blank -->
<input type='file' name='image[]'/> <!-- They put a picture in this one -->
<input type='file' name='image[]'/> <!-- And this one -->
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
<input type='file' name='image[]'/>
If you use the for() loop above, the script will automatically just assume that the first two inputs were used. So the “first” image would be uploaded as the second image and the “second” second image wouldn’t be uploaded.
So this script works, in a way. I’m using javascript to hide the extra inputs unless they say they want to upload another image.