I am trying to create a multiple image upload with description on each image. I have used a jquery coe that allows me to add fields on demand. However, even though the images are uploaded and saved into DB, in the description column I get Array[0]
instead of the actual description..
How can I fix this?
This is the HTML
<form action="upload.php" method="post" enctype="multipart/form-data">
<div class="input_fields_wrap">
<button class="add_field_button">Add More Fields</button>
<div><input type="file" name="file_array[]"><input type="text" name="description[]" placeholder="Write Description"></div>
</div>
<input type="submit" value="Upload all files">
</form>
and here is the upload.php
if(isset($_FILES['file_array'])){
$name_array = $_FILES['file_array']['name'];
$tmp_name_array = $_FILES['file_array']['tmp_name'];
$type_array = $_FILES['file_array']['type'];
$size_array = $_FILES['file_array']['size'];
$error_array = $_FILES['file_array']['error'];
for($i = 0; $i < count($tmp_name_array); $i++){
if(move_uploaded_file($tmp_name_array[$i], "upload/".$name_array[$i])){
mysql_query("INSERT into projects (`image`,`description`) VALUES('$name_array[$i]','$_POST[description][$i]') ");
echo $name_array[$i]." upload is complete<br>";
} else {
echo "move_uploaded_file function failed for ".$name_array[$i]."<br>";
}
}
}