我正在尝试使用FineUploader JS库上传文件。问题是什么都没有上传到所需的目录。我准备好自定义UI,我也需要使用一些表单数据上传文件。我无法理解为什么不上传,以及如何获取进度数据以及上传是否完成。
在控制台中,我得到:[Fine Uploader 5.16.0] Attaching to form element.
HTML
<form id="uploadForm" type="POST" enctype="multipart/form-data">
<div id="inputBlock">
<input id="heading" name="heading" type="text" placeholder="First Name">
<span id="slide"></span>
</div>
<div id="previewContainer">
<div id="preview">
</div>
<div id="overlay" class="hidden">
<div id="checkmark" class="checkmark hidden">
<div class="checkmarkCircle"></div>
<div class="checkmarkStem"></div>
<div class="checkmarkKick"></div>
</div>
</div>
</div>
<input id="fileUpload" name="fileUpload" class="hidden" type="file" accept="image/*" capture="user">
<input id="snapBtn" type="button" value="CAPTURE" disabled>
</form>
JQUERY
$(document).ready(function() {
$("#heading").on("change", function() {
if ($.trim($(this).val()) === "") {
$("#snapBtn").prop("disabled", true).removeClass("btnEnabled");
}
else {
$("#snapBtn").prop("disabled", false).addClass("btnEnabled");
}
});
$("#snapBtn").on("click", function() {
$("#fileUpload").click();
return false;
});
$("#fileUpload").on("change", function(e) {
$("#overlay").hide().css("height", "0");
$("#checkmark").hide();
var uploader = new qq.FineUploaderBasic({
debug: true,
form: {
element: "uploadForm"
},
request: {
endpoint: 'functions/uploadHandler.php'
},
autoUpload: true
});
});
PHP代码段
if($_SERVER["REQUEST_METHOD"] === "POST") {
$error = "";
$message = "";
$name = filter_var($_POST["heading"], FILTER_SANITIZE_STRING);
if(empty($name)) {
$error = "Please type your name..";
}
else {
...