jQuery-File-Upload mysql select显示所有文件,而不仅仅是用户的文件

 v木易杨_920 发布于 2022-12-28 14:47

欢迎,

我有jQuery-File-Upload的问题.我将插件与MySQL集成 - > https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration当我将文件添加到数据库中时添加了记录:name file, id_user, active...这很好.

加载我的网站后,加载列表上传的文件:https://stackoverflow.com/a/15448692/2788495

我只想加载当前加载所有的用户文件.

jQuery代码:

    $.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
    dataType: 'json',
    context: $('#fileupload')[0],
    formData:{
        user: 'e_ident ?>'
    }
}).done(function (result) {
    $(this).fileupload('option', 'done')
        .call(this, null, {result: result});
});

PHP:

protected function handle_form_data($file, $index) {
    $file->title = @$_REQUEST['title'][$index];
    $file->description = @$_REQUEST['description'][$index];
    $file->user=@$_REQUEST['user'];
}
    protected function set_additional_file_properties($file) {
    parent::set_additional_file_properties($file);
    if ($_SERVER['REQUEST_METHOD'] === 'GET') {
        $sql = 'SELECT `id`,`user_id` FROM `'
            .$this->options['db_table'].'` WHERE `name`=? and user_id=?';
        $query = $this->db->prepare($sql);
        $query->bind_param('ss', $file->name, $file->user);
        $query->execute();
        $query->bind_result(
            $id,
            $user
        );
        while ($query->fetch()) {
            $file->id = $id;
            $file->user=$user;
        }
    }
}

在JSON中,没有选项:"id"和"user".

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有