1 回答
TA贡献1719条经验 获得超6个赞
我用过改变。
$(document).ready(function () {
$('#file').unbind().on('change', function () {
$('#img-loag-scrin').html('');
$('div#img-loag-scrin').css('display', 'block').prepend('<img id="img_akb" src="https://' + HTTP + '/images/ajax-loader.gif" id="buff-load" style="display:block;margin:10px auto; cursor: wait;">');
var fd = new FormData();
var files = $('#file')[0].files[0];
fd.append('file', files);
$.ajax({
url: 'https://localhost/ajax/ajax_img.php?act=upload',
dataType: "json",
type: 'post',
cache: false,
data: fd,
contentType: false,
processData: false,
success: function (response) {
if (response != 0) {
$('#img-loag-scrin').prepend(response.scrins);
$('#textrea').val($('#textrea').val() + " " + response.textrea);
$('#img_akb').remove();
} else {
alert('File not uploaded');
}
}
});
});
});
html代码
<form method="post" action="" enctype="multipart/form-data" id="myform">
<input type="file" id="file" name="file">
</form>
- 1 回答
- 0 关注
- 69 浏览
添加回答
举报