Welcome,
I have a problem with jQuery-File-Upload. I turned on the plugin with MySQL -> https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration When I added the file to the database, the record added: name file, id_user, active... Itβs nice to add.
When my site is uploaded, the list of uploaded files is uploaded: https://stackoverflow.com/a/212969/
I want to download only user files that currently download everything.
JQuery Code:
$.ajax({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: $('#fileupload').fileupload('option', 'url'), dataType: 'json', context: $('#fileupload')[0], formData:{ user: '<?php echo $objSession->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; } } }
There is no option in JSON: "id" and "user".
source share