I've got issue with jQuery File Upload (blueimp).
On uploading files I insert
file data to DB. Right after that I can get last insert id. The issue: How can i transmit this value from PHP to JavaScript Template?
To be more clear, I need template like:
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<div class="template-download fade" id="file-{%=file.id%}">
<div class="name"><span>{%=file.name%}</span></div>
....
</div>
{% } %}
</script>
where file.id
is my last insert id that was defined in PHP.
SOLUTUON : Function post in class UploadHandler. Add something like
$info[$index]->myvar= 'something';
then we can use file.myvar
in template.
I had some extra form data, and I had luck with adding them to the function handle_file_upload
$file = new stdClass();
$file->name = $this->trim_file_name($name, $type, $index);
$file->size = $this->fix_integer_overflow(intval($size));
$file->type = $type;
//add additional post variables here:
$file->title = $_POST['title'][$index];
$file->description = $_POST['description'][$index];
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.