I've looked around and have struggled to find out how to upload multiple images (.jpg/.png/etc). For my task I was looking to upload 5 pictures to the database record. So far I'm struggling to even upload 5 together in one record. I've used PHP from the Ws3 website and it works successfully but this code is for one image alone.
PHP Code -
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 2000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . uniqid() . "_" . $_FILES["file"]["name"]);
}
}
}
else
{
$error = "Invalid file";
}
My HTML is as follows,
<label for="file">Filename:</label>
<input type="file" name="file" id="file">
<input type="file" name="file" id="file">
<input type="file" name="file" id="file">
<input type="file" name="file" id="file">
<input type="file" name="file" id="file">
Any advice is greatly appreciated guys! Cheers