function file_up(id){var up_id = 'uploadfiles'+id;var upremv_id = 'upload'+id;var files = document.getElementById(up_id).files;for(var i = 0; i helloworld/index/upload";var xhr = new XMLHttpRequest();var fd = new FormData();xhr.open("POST", url, true);xhr.onreadystatechange = function(){if(xhr.readyState == 4 && xhr.status == 200){jQuery('#imgna'+up_id).val(xhr.responseText);console.log(xhr.responseText);// handle response.jQuery('#'+up_id).remove();jQuery('#'+upremv_id).remove();var img_va = ''+xhr.responseText+'">';jQuery('#pre'+up_id).html(img_va);}};fd.append('uploaded_file', file);
<script>
function file_up(id)
{
var up_id = 'uploadfiles'+id;
var upremv_id = 'upload'+id;
var files = document.getElementById(up_id).files;
for (var i = 0; i < files.length; i++)
{
uploadFile(files[i],up_id,upremv_id);
}
}
function uploadFile(file,up_id,upremv_id){
var url = "<?php echo $baseurl ?>helloworld/index/upload";
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open("POST", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
jQuery('#imgna'+up_id).val(xhr.responseText);
console.log(xhr.responseText); // handle response.
jQuery('#'+up_id).remove();
jQuery('#'+upremv_id).remove();
var img_va = '<img class="image" src="<?php echo $mediaUrl.'custom/'?>'+xhr.responseText+'">';
jQuery('#pre'+up_id).html(img_va);
}
};
fd.append('uploaded_file', file);
</script>