这是一个奇怪的问题,iv在上传小jpeg图像时,dropzone工作正常,但如果我想上传GIF,它就无法工作。
我没有收到任何错误,但它显示$ _POST为空,所以我不认为它被发送到upload.php文件。
这是我的js代码
var previewTemplate = $('#preview-template').html();
$('#preview-template').remove();
Dropzone.options.uploadForm = {
url: 'upload.php',
maxFiles: 10,
previewTemplate: previewTemplate,
previewsContainer: '#uploadForm',
createImageThumbnails: false,
maxFilesize: 100,
init: function() {
this.on("uploadprogress", function(progress) {
//console.log(progress);
//$(".progress-bar").css({"width": progress + "%"});
});
this.on('addedfile', function(file) {
// Called when a file is added to the list.
console.log('added' + file);
});
this.on('sending', function(file, xhr, formData) {
// Called just before each file is sent.
console.log('sending' + file);
});
this.on('success', function(file, json) {
// Called when file uploaded successfully.
console.log('success' + file);
});
}
};
这是我的upload.php文件
ini_set('post_max_size', '100M');
ini_set('upload_max_filesize', '100M');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$storeFolder = 'g/'; //2
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name']; //3
$targetFile = $storeFolder. $_FILES['file']['name']; //5
move_uploaded_file($tempFile,$targetFile); //6
echo "OK";
} else {
var_dump
($_FILES);
}
表格在这里
<form class="dropzone" id="uploadForm" enctype="multipart/form-data">
<div class="dz-message">
<h3>Drag and Drop Gifs Here</h3>
<span class="grey">or click to browse</span>
</div>
<div id="previewsContainer"></div>
<div id="preview-template" style="display:none;">
<div class="dz-details">
<div class="dz-filename"><span data-dz-name></span></div>
<div class="dz-size" data-dz-size></div>
<strong class="error text-danger" data-dz-errormessage></strong>
<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
</div>
</div>
</form>