Hey Row !
Not sure if you're still struggling with this problem,
but I got it working using the following code:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload Test</title>
</head>
<body>
<?php
if(isset($_FILES["upload"]) && !empty($_FILES["upload"])){
$imageCount = count($_FILES["upload"]["name"]);
if($imageCount > 3){
// More than 4 images uploaded.
echo "You can only upload 4 images.";
}
else if($imageCount == 1 && empty($_FILES["upload"]["name"][0])){
// No image uploaded.
echo "No image selected.";
}
else{
$allowedExt = array("jpg", "jpeg", "png", "gif");
for($i = 0; $i < $imageCount; $i++){
$fileName = $_FILES["upload"]["name"][$i];
$fileSize = $_FILES["upload"]["size"][$i];
$extensionArray = explode('.', $fileName);
if( !in_array(end($extensionArray), $allowedExt) ){
// Illegal extension.
echo "Only jpg, jpeg, png, and gif are allowed.";
break;
}
else if($fileSize > 2097152){
// File is too big.
echo "Maximum allowed size is 2MB.";
break;
}
else{
// Process the image.
if(($i + 1) == $imageCount){
// Success message when the last image is processed.
echo "Upload successful !";
}
}
}
}
}
?>
<form action="" enctype="multipart/form-data" method="post">
<input type="file" name="upload[]" multiple="multiple" /> <br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
Note the name of the input tag.
Because of some reason I haven't figured out yet,
it is necessary to write it in an "array notation" when using the "multiple" attribute otherwise only the last image is processed.
Another ugly thing is that the $imageCount will be 1 if you don't upload any image.
This is because $_FILES["upload"]["name"] will contain an empty array by default, for another mysterious reason...
Hope it helps en succes !
Léon
Ps, multiple file upload is not fully supported yet.