Boris
Новичок
Здравствуйте!
Подскажите почему динамически созданные input type="file" по средствам JS
не попадают в $_POST
Спасибо!
Подскажите почему динамически созданные input type="file" по средствам JS
HTML:
<script type="text/javascript">
function insertPreLoad(files,idPreLoadImg)
{
var file = files[0];
var reader = new FileReader();
reader.onload = function (e)
{
document.getElementById("imgPreLoad"+idPreLoadImg).src = e.target.result;
};
reader.readAsDataURL(file);
}
function showFileInput(idLI)
{
var fileInput = document.getElementById("fileInput"+idLI);
fileInput.click();
}
function deleteBlockDetailImg(idDelLI)
{
document.getElementById("BlockDetailImg"+idDelLI).remove();
document.getElementById('butAddDetailImg').style.display = 'block';
}
function addBlockDetailsImg()
{
d = new Date();
idLiAddImg = d.getTime();
document.getElementById('ulAddImg').innerHTML += '<li style="list-style-type: none; margin-top:10px;" id="BlockDetailImg'+idLiAddImg+'"><div class="border_radius" style="border: 1px solid #2f5726; padding:10px;"><div style="float:right;"><input type="file" style="display:none;" name="arrDetailsImg[]" id="fileInput'+idLiAddImg+'" onchange="insertPreLoad(this.files,'+idLiAddImg+')" /><img id="imgPreLoad'+idLiAddImg+'" style="cursor: pointer;" src="images/but_add_img.png" height="180" onclick="showFileInput('+idLiAddImg+')" /></div><div style="float:left;"><img style="cursor: pointer;" src="images/button_delete.png" onclick="deleteBlockDetailImg('+idLiAddImg+')" ></div><div style="clear:both;"></div></div></li>';
showFileInput(idLiAddImg);
if(document.getElementById('ulAddImg').getElementsByTagName('li').length==3)
{
document.getElementById('butAddDetailImg').style.display = 'none';
}
else
{
document.getElementById('butAddDetailImg').style.display = 'block';
}
}
</script>
<form action="/users_cabinet/test_upload_photo.php" method="post" enctype="multipart/form-data" name="form_add_product" >
<div class="border_radius" style="width:600px; padding:10px; border: 1px solid #a2e692; background-image:url(images/bg_png_1_1px.png);">
<ul id="ulAddImg">
</ul>
<div id="butAddDetailImg" style="margin-top:20px;">
<img style="cursor: pointer;" src="images/but_block_add_image.png" onclick="addBlockDetailsImg()" />
</div>
</div>
<div style="margin-top:20px;" align="center">
<input type="hidden" name="submit_users_cabinet_add_product">
<input type="image" src="images/button_save.png" >
</div>
</form>
Спасибо!