I have a difficult problem. Already researched here on the site, and tried many solutions proposed, but none worked in Internet Expolorer 8 (is the version I have installed on my machine). Works fine in Chrome and Firefox. I have a website where the user needs to upload 10 photos. I need make the upload and display them in a div on the page, without flash and without reloading the page. I used the technique of set form target attribute , to do the post in a iframe, the iframe does the post, and when reloaded, it´s just an img tag with the image that was uploaded (I do it at server side script - PHP) In internet explorer the contents of iframe does not change, the post does not happen.
Someone miracle can help me? 've Researched a lot here in the forum, but most of these problems are with iframes dynamically generated by javascript, but in my case, the iframe is already in html
Here is my code:
//javascript
$(document).ready(function() {
//this part works in every browser, is jut´s to triger click in input type file
$(".div_input_file").click(function(){
var rel = $(this).attr("rel");
$(".arq"+rel).trigger('click');
})
});
function loadPicture(number)
{
$(".remover_produto").remove();
//just a gif animation until ends animation
$("#image_load_"+number).attr("src","images/loading.gif");
$("#image_load_"+number).css("width","172px");
$("#image_load_"+number).css("height","176px");
//when iframe load after post
$("#upload_target_"+number).load(function() {
//get image that was loaded in iframe after post
var image = $("#upload_target_"+number).contents().find("img").attr("src");
$("#div_input_file_"+number).html("<img src='"+image+"' alt='' class='img_uploaded' />");
$("#div_input_file_"+number).parent().append('<a class="remover_produto" rel="remover_'+number+'"');
});
}
//html
<iframe id="upload_target_1" class="upload_target" name="upload_target_1" src="upload.php"></iframe>
<div id="div_input_file_1" class="div_input_file" rel="1">
<img src="images/criar_anuncio/gallery_pic05.png" alt="" id="image_load_1" />
</div>
<form action="/upload.php" id="form_upload_1" enctype="multipart/form-data" method="post" target="upload_target_1" onsubmit="loadPicture(1)">
<input name="arquivo" type="file" size="30" class="arquivo arq1" onchange="$('#form_upload_1').submit();"/>
<input type="hidden" name="num_imagem" value="1" />
</form>