gpt4 book ai didi

javascript - Krajee Bootstrap 文件输入无响应

转载 作者:搜寻专家 更新时间:2023-10-31 21:30:06 26 4
gpt4 key购买 nike

我正在尝试使用 this plugin当我点击表单上的提交时,我没有得到任何回复。

这是模态框内的表单。我正在使用 Bootstrap 。

    <form id="myForm" action="#" method="post" enctype="multipart/form-data">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="closeModalTimes">
&times;
</button>
<h4 class="modal-title">Upload New Document</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label">Name *</label>
<input class="form-control" type="text" id="name" name="name" required />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label">Subject *</label>
<textarea name="subject" id="subject" class="form-control" required></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="inputFile">Document File *</label>
<input type="file" name="inputFile" id="inputFile" required>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn" id="closeModalButton">
Close
</button>
<button type='button' id="submitFile" class='btn'>
Send
</button>
</div>
</div><!-- /.modal-content -->
<input name="myId" type="hidden" id="myId" value="393839334034933">
<input name="user" type="hidden" id="user" value="339">
<input name="page" type="hidden" id="page" value="test">
</form>

这是页面底部的jquery

$("#inputFile").fileinput({
overwriteInitial: false,
maxFileSize: 4000,
showPreview: false,
showUpload: false,
uploadAsync: true,
allowedFileExtensions: ["jpg", "jpeg", "gif", "png"],
browseClass: "btn btn-info",
elErrorContainer: "#documentErrorBlock",
msgSizeTooLarge: "File exceeds size",
msgInvalidFileExtension: "Invalid extension",
uploadURL: "upload.php",
uploadExtraData: function() {
return {
id: $("#myId").val(),
userId: $("#user").val(),
page: $("#page").val(),
name: $("#name").val(),
subject: $("#subject").val()
};
}
});


$('#inputFile').on('filebatchuploadsuccess', function(event, data, previewId, index) {
alert('success: '+data.response);
});

$('#inputFile').on('filebatchuploaderror', function(event, data, previewId, index) {
alert('error: '+data.response);
});

$("#submitFile").click(function(e) {
$('#inputFile').fileinput('upload');
});

这是 PHP 文件:

$output = array();
$output['message'] = 'Reached PHP';
$output['success'] = true;
echo json_encode($output);

当我点击时,什么也没有发生……没有错误信息或任何东西……感谢您的帮助!

最佳答案

未提交的原因来自您的“uploadURL”,根据文档拼写错误。改变这个

uploadURL: "upload.php",

uploadUrl: "upload.php",

这解决了您的问题。

http://plugins.krajee.com/file-input#option-uploadurl

关于javascript - Krajee Bootstrap 文件输入无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30877277/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com