I have this code where I upload several images at once and it does the multiple upload like a prophecy but the only problem is that the output is not “evaled” or does not execute any javascript. So for example on the output page if I do
<script> alert('Yes'); </script>
Nothing happens after the upload. Here is the code for multiple upload
<script>
var handleUpload_afile = function(event){
event.preventDefault();
event.stopPropagation();
var fileInput = document.getElementById('afile');
var data = new FormData();
for(var i = 0; i < fileInput.files.length; ++i)
{
data.append('afile[]',fileInput.files[i]);
}
if (window.XMLHttpRequest)
{
// code for modern browsers
xhr_afile = new XMLHttpRequest();
}
else
{
// code for old IE browsers
xhr_afile = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr_afile.upload.addEventListener('progress',function(event){
if(event.lengthComputable)
{
var percent = event.loaded / event.total;
var progress = document.getElementById('upload_progress_afile');
while (progress.hasChildNodes())
{
progress.removeChild(progress.firstChild);
}
}
});
xhr_afile.upload.addEventListener('load',function(event)
{
/*
document.getElementById('upload_progress_afile').style.display = 'none';
*/
});
xhr_afile.upload.addEventListener('error',function(event)
{
alert("failed");
});
xhr_afile.open('POST','upload_multiple_article_gallery_travail.php');
xhr_afile.setRequestHeader('Cache-Control','no-cache');
xhr_afile.upload.onprogress = function(e)
{
if (e.lengthComputable)
{
var percentComplete = (e.loaded / e.total) * 100;
document.getElementById("upload_progress_afile").innerHTML="<img src='images/facebook_style_loader.gif' width='16' height='11'> <br>" + (Math.round(percentComplete)-1) + ' % uploding';
}
};
xhr_afile.onload = function()
{
if (this.status == 200)
{
if (document.getElementById)
{
document.getElementById("upload_progress_afile").innerHTML=xhr_afile.responseText;
}
}
};
xhr_afile.send(data);
};
//We submit the form as soon as the file changes
var uplodons = document.getElementById('afile');
uplodons.addEventListener('change',handleUpload_afile);
</script>
On the page upload_multiple_article_gallery_travail.php I need to be able to call and execute javascript but it does not work. So how to eval the output after upload so the javascript on the page upload_multiple_article_gallery_travail.php will be executed ?