$(“body”)。addClass(“loading”);被解雇(这是加载模式),所以我不知道什么时候没有运行image-upload.php。
谢谢大家:)
使用Javascript:
var wrapper = $('<div/>').css({height:0,width:0,'overflow':'hidden'});
var fileInput = $('#file').wrap(wrapper);
$('.chooseFile').click(function(){
fileInput.click();
}).show();
$(document).ready(function() {
fileInput.change(function ()
{
$("body").addClass("loading");
//uploadImg.submit();
$('#uploadImg').submit();
this.blur();
this.focus();
});
});
HTML
<form name="uploadImg" id="uploadImg" action="image-upload.php" method="post" enctype="multipart/form-data" class="btnFile">
<div class="chooseFile">Choose File</div>
<input type="file" id="file" name="file" value="Select File to Upload" accept="image/*">
</form>
答案 0 :(得分:1)
您需要使用
var wrapper = $('<div/>').css({height:0,width:0,'overflow':'hidden'});
var fileInput = $('#file').wrap(wrapper);
$('.chooseFile').click(function(){
fileInput.click();
}).show();
内
$(document).ready(function() {