user1029829
user1029829

Reputation: 961

How to submit dynamic variables with uploadifive

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

Answers (3)

Jenny Nalzaro
Jenny Nalzaro

Reputation: 31

DO THIS PROCEDURE and do not deviate:

  1. Torch this option from your jQuery script (yes, remove it):

    'formData' : {
        'timestamp' : '<?php echo $timestamp;?>',
        'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
    },
    
  2. 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'];
    
  3. 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

RationalRabbit
RationalRabbit

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

Dejan Cancarevic
Dejan Cancarevic

Reputation: 197

try

uploadify_obj.data('uploadifive').settings.uploadScript = ""

Upvotes: 1

Related Questions