简体   繁体   中英

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

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

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()
      },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM