php无法完成文件上传,php – Fine Uploader无法上传文件

我正在使用文件上传器jquery插件,以便在我的网站上上传ajax文件.但是,我只是无法弄清楚出了什么问题以及为什么它不起作用.

我的代码:

我直接从他们的演示中获取了代码:

$(document).ready(function() {

$fub = $('#fine-uploader-basic');

$messages = $('#messages');

var uploader = new qq.FileUploaderBasic({

button: $fub[0],

action: 'http://localhost/script/file_upload/upload_test',

debug: true,

allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],

sizeLimit: 204800, // 200 kB = 200 * 1024 bytes

onSubmit: function(id, fileName) {

$messages.append('

},

onUpload: function(id, fileName) {

$('#file-' + id).addClass('alert-info')

.html('Initializing. Please hold.' +

'Initializing ' +

'“' + fileName + '”');

},

onProgress: function(id, fileName, loaded, total) {

if (loaded < total) {

progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';

$('#file-' + id).removeClass('alert-info')

.html('In progress. Please hold.' +

'Uploading ' +

'“' + fileName + '” ' +

progress);

} else {

$('#file-' + id).addClass('alert-info')

.html('Saving. Please hold.' +

'Saving ' +

'“' + fileName + '”');

}

},

onComplete: function(id, fileName, responseJSON) {

if (responseJSON.success) {

$('#file-' + id).removeClass('alert-info')

.addClass('alert-success')

.html(' ' +

'Successfully saved ' +

'“' + fileName + '”' +

'' + fileName + '');

} else {

$('#file-' + id).removeClass('alert-info')

.addClass('alert-error')

.html(' ' +

'Error with ' +

'“' + fileName + '”: ' +

responseJSON.error);

}

}

});

});

HTML:

Click to upload

PHP:

public function upload_test() {

$upload = move_uploaded_file('./user_files', $_FILES['qqfile']['tmp_name']);

if($upload) {

echo json_encode(array('success' => true));

} else {

echo json_encode(array('success' => false, 'error' => $upload));

}

}

我认为问题在于PHP,但我无法弄清楚我做错了什么.在我疯了之前请帮忙.

谢谢.

解决方法:

我没有读过你的js和html部分,但是你需要改变你的PHP部分.

看看他是怎么做到的

标签:php,jquery,ajax,file-upload,fine-uploader

来源: https://codeday.me/bug/20190826/1725613.html