Blueimp Jquery fileuploader无法正常工作

时间:2018-08-16 11:31:45

标签: php jquery upload blueimp

我正在尝试实现Jquery文件unloader(blueimp)的简单脚本。但这不起作用。我不确定这是什么错误。我已经搜索过它,甚至已经阅读了文档,但是找不到任何帮助,因此将其粘贴到此处。尝试了此操作-https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin#how-to-use-only-the-basic-plugin-minimal-setup-guide。我的PHP脚本是

SELECT ep.*
FROM EmployeeProfile ep
WHERE EXISTS (SELECT 1 
              FROM EmployeeProfile ep1 
              WHERE ep1.Email = ep.Email AND ep1.EmployeeId <> ep.EmployeeId
             );

我的html和JS代码是

<?php

// A list of permitted file extensions
$allowed = array('png', 'jpg', 'gif','zip', 'html','php', 'py');

if(isset($_FILES['upl']) && $_FILES['files']['error'] == 0){

$extension = pathinfo($_FILES['files']['name'], PATHINFO_EXTENSION);

if(!in_array(strtolower($extension), $allowed)){
    echo '{"status":"error"}';
    exit;
}

if(move_uploaded_file($_FILES['files']['tmp_name'], __DIR__.'/upl   /'.$_FILES['files']['name'])){
    echo '{"status":"success"}';
    exit;
}
}

echo '{"status":"error"}';
exit;
?>

我什至给执行此操作的目录777权限。当我登录<html> <head> <title>smaple upload</title> </head> <body> <input id="fileupload" type="file" name="files[]" multiple data-url="act.php"> <script src="../upload_proj/js/jquery.min.js"></script> <script src="up/js/vendor/jquery.ui.widget.js"></script> <script src="up/js/jquery.iframe-transport.js"></script> <script src="up/js/jquery.fileupload.js"></script> <script> $(function () { $('#fileupload').fileupload({ dataType: 'json', start: function (e) { console.log('start'); }, done: function (e, data) { console.log("sample"); console.log(data.result.files); $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo(document.body); }); } }); }); </script> </body> </html> 时。我在控制台中打印了未定义的内容。谢谢!

0 个答案:

没有答案