I'm trying to upload multiple files at once but have a solo form field to define the name of the column that will define the gallery name... I tried different scripts and methods but the only one I've been successful with is this one, except I have to type the name of the gallery in each one, is there a way to do this?
Here's my HTML form
<form action="php_multiple_upload2.php" method="post" name="form1" enctype="multipart/form-data">
<input type="text" name="galnom1"><input type="file" name="fileUpload1" ><br>
<input type="text" name="galnom2"><input type="file" name="fileUpload2"><br>
<input type="text" name="galnom3"><input type="file" name="fileUpload3"><br>
<input type="text" name="galnom4"><input type="file" name="fileUpload4"><br>
<input name="hdnLine" type="hidden" value="4">
<input name="btnSubmit" type="submit" value="Submit">
</form>
Here's the PHP Code
<?php
include("../../cnf/cnctr.php");
for($i=1;$i<=(int)($_POST["hdnLine"]);$i++)
{
if($_FILES["fileUpload".$i]["name"] != "")
{
if(copy($_FILES["fileUpload".$i]["tmp_name"],"img/".$_FILES["fileUpload".$i]["name"]))
{
$strSQL = "INSERT INTO galeria ";
$strSQL .="(galnom,ttl) VALUES ('".$_POST["galnom".$i]."','".$_FILES["fileUpload".$i]["name"]."')";
mysqli_query($fsn,$strSQL);
echo "Copy/Upload ".$_FILES["fileUpload".$i]["name"]." completed.<br>";
}
}
}
echo "<br><a href='php_multiple_upload6.php'>View file</a>";
mysqli_close($fsn);
?>
This is how I envision my html form:
<form action="php_multiple_upload2.php" method="post" name="form1" enctype="multipart/form-data">
<input type="text" name="gallery_name"><br> <!-- Just one field to name the gallery -->
<input type="file" name="fileUpload1" ><br>
<input type="file" name="fileUpload2"><br>
<input type="file" name="fileUpload3"><br>
<input type="file" name="fileUpload4"><br>
<input name="hdnLine" type="hidden" value="4">
<input name="btnSubmit" type="submit" value="Submit">
</form>
As always thanks for the help :)
Best Regards