我已经看到其他人如何捕获从其上传者后端返回的数据。 (请参阅:How do i get swfupload to return image URL after upload?)但是我仍然在.bind()上遇到JavaScript错误。有任何想法吗?

码:
        upload1 =新的SWFUpload({

      // Backend Settings
      upload_url: "uploader2.py",
      post_params: various params,

      // File Upload Settings <a id="printimages" style="float: right">Print Images</a>
      file_size_limit : "100 MB",     // 100MB
      file_types : "",
      file_types_description : "Any File",
      file_upload_limit : 1000,
      file_queue_limit : 0,

      // Event Handler Settings (all my handlers are in the Handler.js file)
      swfupload_preload_handler : preLoad,
      swfupload_load_failed_handler : loadFailed,
      file_dialog_start_handler : fileDialogStart,
      file_queued_handler : fileQueued,
      file_queue_error_handler : fileQueueError,
      file_dialog_complete_handler : fileDialogComplete,
      upload_start_handler : uploadStart,
      upload_progress_handler : uploadProgress,
      upload_error_handler : uploadError,
      upload_success_handler : uploadSuccess,
      upload_complete_handler : uploadComplete,

      // Button Settings
      button_image_url : "images/XPButtonUploadText_61x22.png",
      button_placeholder_id : "ButtonPlaceholder1",
      //button_placeholder : "spanButtonPlaceholder1",
      button_width: 61,
      button_height: 22,
      moving_average_history_size: 1,

      // Flash Settings
      flash_url : "swf/swfupload.swf",
      flash9_url : "swf/swfupload_fp9.swf",

       // My settings
      custom_settings : {
        progressTarget : "fsUploadProgress1",
        cancelButtonId : "btnCancel1",
        tdFilesQueued : document.getElementById("tdFilesQueued"),
        tdFilesUploaded : document.getElementById("tdFilesUploaded"),
        tdErrors : document.getElementById("tdErrors"),
        tdCurrentSpeed : document.getElementById("tdCurrentSpeed"),
        tdCurrentFile : document.getElementById("tdCurrentFile"),
        tdAverageSpeed : document.getElementById("tdAverageSpeed"),
        tdMovingAverageSpeed : document.getElementById("tdMovingAverageSpeed"),
        tdTimeRemaining : document.getElementById("tdTimeRemaining"),
        tdTimeElapsed : document.getElementById("tdTimeElapsed"),
        tdPercentUploaded : document.getElementById("tdPercentUploaded"),
        tdSizeUploaded : document.getElementById("tdSizeUploaded"),
        tdProgressEventCount : document.getElementById("tdProgressEventCount")
      },

      // Debug Settings

      debug: false
   }).bind('uploadSuccess', function(event, file, serverData){
      alert(serverData);
  });

最佳答案

链接的示例使用swfupload jquery plugin,并且具有绑定功能。您的示例使用的是不带jquery的插件,因此当您对新的SWFUpload对象调用bind时,会出现错误,因为它没有bind方法。使它起作用的最简单方法是实现回调函数。

// Backend Settings
upload1= new SWFUpload({
  upload_url: "uploader2.py",
  post_params: various params,

  // File Upload Settings <a id="printimages" style="float: right">Print Images</a>
  file_size_limit : "100 MB",     // 100MB
  file_types : "",
  file_types_description : "Any File",
  file_upload_limit : 1000,
  file_queue_limit : 0,

  // Event Handler Settings (all my handlers are in the Handler.js file)
  swfupload_preload_handler : preLoad,
  swfupload_load_failed_handler : loadFailed,
  file_dialog_start_handler : fileDialogStart,
  file_queued_handler : fileQueued,
  file_queue_error_handler : fileQueueError,
  file_dialog_complete_handler : fileDialogComplete,
  upload_start_handler : uploadStart,
  upload_progress_handler : uploadProgress,
  upload_error_handler : uploadError,
  upload_success_handler : myUploadSuccessHandler,
  upload_complete_handler : uploadComplete,

  // Button Settings
  button_image_url : "images/XPButtonUploadText_61x22.png",
  button_placeholder_id : "ButtonPlaceholder1",
  //button_placeholder : "spanButtonPlaceholder1",
  button_width: 61,
  button_height: 22,
  moving_average_history_size: 1,

  // Flash Settings
  flash_url : "swf/swfupload.swf",
  flash9_url : "swf/swfupload_fp9.swf",
  },

  // Debug Settings

  debug: true
 });

 // your callback
 function myUploadSuccessHandler (file, serverData){
    alert(file, serverData);
 }


另一个有用的事情是将debug选项设置为true :)

关于javascript - SWFupload网址回调,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5479616/

10-11 13:36