简体   繁体   中英

BlueImp File upload extra parameter

I am trying to pass an extra parameter to the blueimp file upload. And I tried using the file upload submit event:

$('#fileupload').bind('fileuploadsubmit', function (e, data) {
// The example input, doesn't have to be part of the upload form:
var input = $('#input');
data.formData = {example: input.val()};
if (!data.formData.example) {
  data.context.find('button').prop('disabled', false);
  input.focus();
  return false;
}
});

However I have no idea where that extra parameter is being passed to and how to access that extra paremeter?

What I am trying to achieve is to assign a unique id to each row when the files are uploaded in the UI version. Any suggestions?

In your upload-template javascript add the field

 <td> Descripción <input type="text" name="descripcion[]" id="descripcion" placeholder="Descripción"> </td> 
In your jQueryFileUpload

 }).on('fileuploadsubmit', function (e, data) { var inputs = data.context.find(':input'); if (inputs.filter(function () { return !this.value && $(this).prop('required'); }).first().focus().length) { data.context.find('button').prop('disabled', false); return false; } data.formData = data.context.find(':input').serializeArray(); }); 

First, the template-download add this code

 <td> {%=file.descripcion%} </td> 

And then modifies your custom index.php "set_additional_file_properties ($ file)" function

 protected function set_additional_file_properties($file) { parent::set_additional_file_properties($file); if ($_SERVER['REQUEST_METHOD'] === 'GET') { $sql = "SELECT Id, Nombre, Descripcion FROM tabla WHERE Nombre='".$file->name."'"; $query = $this->db->prepare($sql); $query->execute(); $query->bind_result( $id, $nombre, $descripcion ); while ($query->fetch()) { $file->id = $id; $file->nombre = $nombre; $file->descripcion = utf8_encode($descripcion); } } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM