我正在尝试使用YUI上传器,但单击浏览按钮时无法打开文件对话框窗口。我正在(或多或少)关注example on Yahoos demo

这是我的HTML代码:

<div id="fileProgress">
  <input id="fileName" type="text" size="40" />
  <input id="uploaderUI" name="uploaderUI" class="submitButton" type="button" value="Browse" />
  <input id="uploadFile" name="uploadFile" class="submitButton" type="button" value="Upload" />
    <div id="progressBar"></div>
</div>


这是我的javasctips代码:

jQuery(document).ready(function() {
    initYUIUpload();
});

  function initYUIUpload()
  {
    YAHOO.widget.Uploader.SWFURL = "wp-includes/js/yui/assets/uploader.swf";
    var uploader = new YAHOO.widget.Uploader("uploaderUI");

    uploader.addListener('contentReady', handleContentReady);
    uploader.addListener('fileSelect',onFileSelect)
    uploader.addListener('uploadStart',onUploadStart);
    uploader.addListener('uploadProgress',onUploadProgress);
    uploader.addListener('uploadCancel',onUploadCancel);
    uploader.addListener('uploadComplete',onUploadComplete);
    uploader.addListener('uploadCompleteData',onUploadResponse);
    uploader.addListener('uploadError', onUploadError);

    jQuery('#uploadFile').click(function(){ upload() });
  }



更新
我使用YUI上传器“放弃”,现在正在使用Uploadify。

最佳答案

我有这个完全相同的问题。

2.8版本的uploader.swf有一个错误

如果您遇到与我相同的问题,那么切换到2.7版本的uploader.swf会使您的事件按预期触发。

10-06 04:00