I am using the following script for a file upload progress bar. Everything works fine except for the echo command in my php script test2.php.
Once the file is uploaded, I do an echo to display "File Uploaded" with the bold tags within the test2.php and the print out will display "File Uploaded" along with the bold tags as opposed to making it bold.
Nothing is wrong with the test2.php becuase if I go to that page directly, then that text is printed in bold.
$(function() {
$('#btn').click(function() {
$('.myprogress').css('width', '0');
$('.msg').text('');
var filename = $('#filename').val();
var myfile = $('#myfile').val();
var formData = new FormData();
formData.append('myfile', $('#myfile')[0].files[0]);
formData.append('filename', filename);
$('#btn').attr('disabled', 'disabled');
$('.msg').text('Uploading in progress...');
$.ajax({
url: 'test2.php',
data: formData,
processData: false,
contentType: false,
type: 'POST',
// this part is progress bar
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt) {
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
percentComplete = parseInt(percentComplete * 100);
$('.myprogress').text(percentComplete + '%');
$('.myprogress').css('width', percentComplete + '%');
$('.myProgress').css("background-color", "#0078ae");
}
}, false);
return xhr;
},
success: function(data) {
$('.msg').text(data);
$('#btn').removeAttr('disabled');
}
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="myform1" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>Rename Firmware File <i>(optional)</i> </label>
<input class="form-control" type="text" id="filename" />
</div>
<div class="form-group">
<input type="file" id="myfile" />
</div>
<div class="form-group">
<div class="progress">
<div class="progress-bar progress-bar-success myprogress" role="progressbar" style="width:0%;">0%</div>
</div>
<div class="msg"></div>
</div>
<input type="button" id="btn" class="ui-button" value="Upload" />
</form>
htmlmethod instead oftext($('.msg').html(data);)