2012-03-14 75 views
1

我使用XUpload Extension来多上传到我的网站的基础yii框架。它工作得很好。直到我尝试重命名上传文件夹,xupload上传失败!我可以预测这种情况。但我不知道如何创建回调时上传成功或失败时,显示在我的网站通知:如何通过Yii上的XUpload Extension上传失败时创建回调函数?

这是Oficial Xupload Extension page

这是我的代码:

$this->widget(
    $className = 'ext.xupload.XUploadWidget', 
    $properties = array(
     'url' => "http://localhost/Upload/multiupload.php"), 

     ...//another config here 

     'options' => array(
      'beforeSend' => 'js:function(event, files, index, xhr, handler, callBack) { 
       handler.uploadRow.find(".upload_start button").click(callBack); 
      }', 

      //Callback function when upload complete 
      'onComplete'=>'js:function(event, files, index, xhr, handler, callBack) { 
       if(xhr.status==200) { 
        alert("Ok"); 
       } else { 
        alert("Error"+ xhr.status); 
       } 
      }', 
     ), 
    ) 
); 

你上传成功时可以看到onComplete事件正在运行,但上传失败时不会。如何处理上传失败事件?

+0

我被找到了答案!我必须使用'onError'而不是'onComplete','xupload'小部件可以处理上传失败事件! – Davuz 2012-03-14 16:32:01

回答

1

以供将来参考:

也有一些是像在jquery.fileupload.js文件“失败”。

 // Callback for failed (abort or error) uploads: 
     // fail: function (e, data) {}, // .bind('fileuploadfail', func);