Uploadifive formdata results in PHP Undefined Index

I have a form that after save shows the upload controls and I use ‘JSON.stringify(myObject)’ to generate a JSON object to pass to uploadifive so my upload.php file can create a db record, this resolves to {‘record_type’:‘project’,‘id’:“1”}.

php is reporting an undefined index for ‘record_type’ and ‘id’, the file itself uploads successfully. how do I pass the variable to uploadifive and execute it correctly so PHP can get access to the index values.

For those that may be thinking PHP cannot read json natively, the plugin is suppose to convert JSON to a $_POST array.

$(document).ready(function () {
....... //some other code
.......

   $(function(myUploadFormData){
    $('#file_input').uploadifive({
        'auto'              : false,
        'multi'             : false,
        'buttonClass'       : 'button',
        'formData'          : myUploadFormData,
        'buttonText'        : 'Select',
        'uploadLimit'       : 1,
        'queueID'           : 'droplist',
        'width'             : 75,
        'height'            : "25px",
        'queueSizeLimit'    : 1,
        'uploadScript'      : 'php/upload.php',
        'onUploadComplete'  : function(file, data) { console.log(data); }
     });
  });

  $("#file_upload").on("click", function() {
      $("#file_input").uploadifive('upload');
  });

});

function uploadFormData(id, record_type){
var myObject = new Object();
myObject.record_type = record_type;
myObject.id = id;
var myUploadFormData = JSON.stringify(myObject);
}

This is a PHP related question more than anything since the error is occurring server side, could you please post your PHP code so we can get a picture of what’s happening on the other side of the request.

Just resolved this using the following code to update the settings of the plugin. Uploadifive loaded on the initial display of the page when there was no record so formdata was ‘undefined’ defining the settings for formData just prior to upload has done the trick.

var record_id = $("#id").val();
    var record_type = "apples";

    $('#file_input').data('uploadifive').settings.formData = {'record_type': record_type,'record_id': record_id };