Javascript-upload failed tokennotspecified

Source: Internet
Author: User
If the same code is uploaded under www.a.com normally at www. B .com and the same code is obtained through www.a.com, the error message "error: & quot;" is returned when the token is uploaded; in tokennotspecifieduptoken_func, after the uptoken returns a null value, it is assigned a value for the data called back by ajax. Therefore, upload the data... same code
Normal Upload at www.a.com
Under www. B .com, if the same code is obtained through www.a.com, the error message "token not specified" is returned.

In uptoken_func, after the uptoken returns a null value, it is assigned a value for the data called back by ajax. Therefore, the token is empty during upload.

Var qiniu_up = qiniu. uploader ({runtimes: 'html5, flash, html4', browse_button: 'qiniu _ browse', get_new_uptoken: true, unique_names: false, save_key: true, domain :'
  ', Container: 'container', max_file_size: '4mb', flash_swf_url :'
  ', Silverlight_xap_url :'
  ', Max_retries: 1, dragdrop: false, drop_element: 'container', chunk_size: '4mb', auto_start: false,/* automatic Upload not enabled */multi_selection: false, /* set to select only one file */filters: {mime_types: [{title: 'image files', extensions: 'jpg, jpeg, gif, png, bmp '}, {title: 'Voice files', extensions: 'MP3, wav '}]}, init :{}, uptoken_func: function (file) {var uptoken = ''; var media_info = '[{"directory": "1", "directory_class": "", "up_file_name": "' + file. name + '"," media_type ":" 1 "}]'; $. ajax ({type: "post", async: false,/* must use synchronization */url :'
  ', Data: {app_version:' 1. 0', app_target: 3, sdk_version: '1. 0 ', plat: 'other', media_info: media_info}, dataType: "jsonp", jsonp: "jsonpCallback", success: function (data) {if (data. code = '1') {var list = data. data. uptoken_list; uptoken = list [0] ['uptoken']; media_id = list [0] ['media _ id'];} else {alert (data. message) ;}}, error: function (XMLHttpRequest, textStatus, errorThrown) {}}); return uptoken ;}});

Reply content:

Same code
Normal Upload at www.a.com
Under www. B .com, if the same code is obtained through www.a.com, the error message "token not specified" is returned.

In uptoken_func, after the uptoken returns a null value, it is assigned a value for the data called back by ajax. Therefore, the token is empty during upload.

Var qiniu_up = qiniu. uploader ({runtimes: 'html5, flash, html4', browse_button: 'qiniu _ browse', get_new_uptoken: true, unique_names: false, save_key: true, domain :'
  ', Container: 'container', max_file_size: '4mb', flash_swf_url :'
  ', Silverlight_xap_url :'
  ', Max_retries: 1, dragdrop: false, drop_element: 'container', chunk_size: '4mb', auto_start: false,/* automatic Upload not enabled */multi_selection: false, /* set to select only one file */filters: {mime_types: [{title: 'image files', extensions: 'jpg, jpeg, gif, png, bmp '}, {title: 'Voice files', extensions: 'MP3, wav '}]}, init :{}, uptoken_func: function (file) {var uptoken = ''; var media_info = '[{"directory": "1", "directory_class": "", "up_file_name": "' + file. name + '"," media_type ":" 1 "}]'; $. ajax ({type: "post", async: false,/* must use synchronization */url :'
  ', Data: {app_version:' 1. 0', app_target: 3, sdk_version: '1. 0 ', plat: 'other', media_info: media_info}, dataType: "jsonp", jsonp: "jsonpCallback", success: function (data) {if (data. code = '1') {var list = data. data. uptoken_list; uptoken = list [0] ['uptoken']; media_id = list [0] ['media _ id'];} else {alert (data. message) ;}}, error: function (XMLHttpRequest, textStatus, errorThrown) {}}); return uptoken ;}});

The landlord's code seems to be uploading files to Qiniu CDN.
The owner of the token issue can check whether there is a JS cross-origin issue. you can also refer to the development documentation of Qiniu or contact the technical staff of Qiniu for joint debugging.

After ajax under uptoken_func is cross-origin, his running order changes. after all the programs are executed, the uptoken under success is assigned a value. Therefore, the uploaded uptoken is empty.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.