新建网页
新建网页
$(function () {
$('#iosPack').change(function (){
$('#progress-div').css('display','')
$('#progress-bar').css('width','0%')
$('#iosErrorMsg').html('')
var formData = new FormData();
// var file = document.getElementById('iosPack').files[0] 效果同下
var file = $('#iosPack')[0].files[0]
formData.append('file',file);
var xhr = new XMLHttpRequest();
xhr.open('POST','{{ path('acme_admin_app_dealAppUpload') }}',true);
xhr.upload.onprogress = function (ev) {
if(ev.lengthComputable) {
var percent = 100 * ev.loaded/ev.total;
$('#progress-bar').css('width',percent+'%')
}
}
xhr.upload.onload = function (){
$('#progress-bar').css('width','100%')
}
xhr.onreadystatechange = function () {
if(this.readyState == 4) {
var data = xhr.responseText
data = $.parseJSON(data)
if(data.error ==0){
$('#iosDownLink').val(data.plistDownLink)
}else{
$('#iosErrorMsg').html(data.errormsg)
$('#iosErrorMsg').css('color','red')
}
}
}
xhr.send(formData);
})