Reputation: 961
I'm using the HTML version of the script. I'm trying to read a dynamic version of the drop down and submit it with the files. The manual says that the onUploadStart should do it however in my case it doesn't work. It looks like the alert that I've put inside to test it is not triggered:
$(function() {
$('#file_upload').uploadifive({
'auto': false,
'formData': {
'timestamp': '<?php echo $timestamp; ?>',
'token': '<?php echo md5('unique_salt' . $timestamp); ?>',
},
'queueID': 'queue',
'uploadScript': 'contractor-access-login-new.php?ACTION=UPLOAD',
'fileObjName': 'file[]',
'onUploadStart': function(file) {
alert("TEST");
var folder = $('select[name=category] option:selected').val();
var formData = { 'folder': folder };
$('#file_upload').uploadifive("settings", "formData", formData);
}
});
});
Is there any other way to submit dynamic variables? Why this method doesn't work?
Upvotes: 1
Views: 1984
Reputation: 31
DO THIS PROCEDURE and do not deviate:
Torch this option from your jQuery script (yes, remove it):
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
Edit your uploadifive.php script. Add these three statements:
$_POST['timestamp'] = time();
$_POST['token'] = md5('unique_salt' . $_POST['timestamp']);
$additional_form_data = $_POST['additional_form_data'];
Go back to your jQuery script, and add this option:
'onUpload' : function(){
$('#file_upload').data('uploadifive').settings.formData = { 'additional_form_data' : $('#additional_form_data').val() }
},
That's it.
Upvotes: 3
Reputation: 1067
You have to move formData out of the initialization entirely and call a function on upload. See my post on this page
Upvotes: 1
Reputation: 197
try
uploadify_obj.data('uploadifive').settings.uploadScript = ""
Upvotes: 1