uploadify Uncaught TypeError: Cannot read property 'toString' of undefined

4k views Asked by At

I am trying to figure out what is wrong with uploadify.

Chrome gives me the following error when I try to use uploadify: Uncaught TypeError: Cannot read property 'toString' of undefined

Here is my html:

<li id="avatarUploadContainer">
  <div id="avatarUploaderDiv" style="position: relative; margin-top: 10px;">
    <input id="avatarUploader" name="avatarUploader" type="file" buttonText="upload">
  </div>
</li>

Here is my javascript to initialize uploadify:

$(function() {
  $('#country').change(function() {
    var countryID = $(this).val();
    getStateList(countryID);
  });


  /*
   * Include flash uploader for avatar uploading
   */

  $('#avatarUploader').click(function(){
    var uploaderPath = baseURL + '/actions.php?action=updateAccountInfo&mode=avatarUpload&umem_id=' + $('#umem_id').val() + '&ms_id=' + $('#membership_id').val();
    var buttonText = $('#avatarUploader').attr('buttonText');
    var fileExt = '.jpg;';
    console.log(uploaderPath);
    console.log(buttonText);
    console.log(fileExt);
    $("#avatarUploader").uploadify({
      'formData': {
        'securityTimestamp': $('#securityTimestamp').val(),
        'securityToken': $('#securityToken').val()
      },
      'height': 14,
      'swf': baseURL + '/assets/uploadify/uploadify.swf',
      'uploader': uploaderPath,
      'multi': false,
      'buttonText': buttonText,
      'folder': baseURL + "/assets/avatars/",
      'fileTypeDesc': 'Images',
      'fileTypeExts': fileExt,
      'fileSizeLimit': $('#maxUploadSize').val(),
      'width': 146,
      'preventCaching': true,


      'onQueueComplete': function(queueData) {

        $('#editorAvatar').attr('src', baseURL + '/avatar.php?size=150&memID=' + $('#mem_id').val());
        $('#memNavAvatar').attr('src', baseURL + '/avatar.php?size=100&memID=' + $('#mem_id').val());

      }
    });

  });
});

My php doesn't even get executed as far as I have tested.

Any help will be greatly appreciated

1

There are 1 answers

0
teremin On

your problem might be solved already, but anyway... this error might occur, if the Form Data contains invalid Data Fields.

To be more specific: either $('#securityTimestamp').val() or $('#securityToken').val() might be undefined.

'formData': {
        'securityTimestamp': $('#securityTimestamp').val(),
        'securityToken': $('#securityToken').val()
      },