Warning: Undefined array key "image"
Showing this error when I'm uploading files in folder and database, I guess my code has mistake.
HTML CODE
<form action="image.php" method="post">
<div class="row">
<div class="col">
<div class="avatar-upload">
<div class="avatar-edit">
<input type='file' id="imageUpload" name="image[]" accept=".png, .jpg, .jpeg" />
<label for="imageUpload"></label>
</div>
<div class="avatar-preview">
<div id="imagePreview" name="image[]"style="background-image: url('../../images/<?
=getuserimagesinfo($db,$user['id'])?>');">
</div>
</div>
</div>
</div>
</form>
Javascript
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#imagePreview').css('background-image', 'url('+e.target.result +')');
$('#imagePreview').hide();
$('#imagePreview').fadeIn(650);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imageUpload").change(function() {
readURL(this);
});
PHP Code
$image_name=$_FILES['image']['name']; //Storing image name
$img_tmp=$_FILES['image']['tmp_name'];
print_r($image_name);
print_r($img_tmp);
If I am inserting name="image[]" in wrong input then please suggest me one, Thanks in advance