I am trying to insert additional Form Data to MYSQL via Blueimp jquery file uploader. But I have some problems.
I am using demo settings and I changed my template-upload to following code (* I added Notunuz input)
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="title"><label>Notunuz: <input name="title[]"></label></td>
{% if (file.error) { %}
<td class="error" colspan="2"><span class="label label-important">Hata</span> {%=file.error%}</td>
{% } else if (o.files.valid && !i) { %}
<td>
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="start">{% if (!o.options.autoUpload) { %}
<button class="btn btn-primary">
<i class="icon-upload icon-white"></i>
<span>Başlat</span>
</button>
{% } %}</td>
{% } else { %}
<td colspan="2"></td>
{% } %}
</tr>
{% } %}
</script>
.js
and UploadHandler.php
file?My second question is How to redirect to specific URL upload is done?
There are multiple ways for sending additional FormData,
1.Static Form Data (If the formdata are never changed on runtime) :
Initialize FileUpload using ,
$('#fileupload').fileupload({
formData: {
"data1": data1,
"data2": data2
}
});
2.Dynamic FormData
Use fileuploadsubmit
for setting FormData on submit event
$('#formData').fileupload({
.........
}).on('fileuploadsubmit', function (e, data) {
data.formData = {
"data1": data1,
"data2": data2
};
});
For More Details See :
I used like,
$('#fileupload').fileupload({
formData: {example: 'test'}
});
To be more dynamic,
<input type="text" name="name" value="" id="inpName" /> /* example 1 */
<span id="spnHash" style="display:none">ttt-vvv-hh</span> /* example 2 */
$('#fileupload').fileupload({
var $formData = {
"name": $("#inpName").val(),
"hash": $("#spnHash").text()
}
formData: $formData
});
For redirect:
https://github.com/blueimp/jQuery-File-Upload/issues/670#issuecomment-2291997
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With