2012-01-03 93 views
1

我不想這樣做。我開始在下載包中找到一個樣本,並根據我的需要進行編輯。 我在php服務器文件腳本中做了擴展驗證,所以如果擴展名不在白名單中,那麼腳本會退出並顯示錯誤。 我不知道如何獲得自定義消息的作品。使用swfupload處理錯誤

有PHP函數

function HandleError($message) { 
    header("HTTP/1.1 500 Internal Server Error"); 
    echo $message; 
} 

但是這回只有500來代替$消息!這是JS uploadError()

function uploadError(file, errorCode, message) { 
try { 
    var progress = new FileProgress(file, this.customSettings.progressTarget); 
    progress.setError(); 
    progress.toggleCancel(false); 

    switch (errorCode) { 
    case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: 
     progress.setStatus("Errore upload: " + message); 
     this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message); 
     break; 
    case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: 
     progress.setStatus("Upload fallito."); 
     this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     break; 
    case SWFUpload.UPLOAD_ERROR.IO_ERROR: 
     progress.setStatus("Errore Server (IO)"); 
     this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message); 
     break; 
    case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: 
     progress.setStatus("Errore Security"); 
     this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message); 
     break; 
    case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: 
     progress.setStatus("Limite upload superato."); 
     this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     break; 
    case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: 
     progress.setStatus("File non valido. Upload ignorato."); 
     this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     break; 
    case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: 
     // If there aren't any files left (they were all cancelled) disable the cancel button 
     if (this.getStats().files_queued === 0) { 
      document.getElementById(this.customSettings.cancelButtonId).disabled = true; 
     } 
     progress.setStatus("Cancellato."); 
     progress.setCancelled(); 
     break; 
    case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: 
     progress.setStatus("Sospeso."); 
     break; 
    default: 
     progress.setStatus("Errore non gestito: " + errorCode); 
     this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     break; 
    } 
} catch (ex) { 
    this.debug(ex); 
} 

如果我註釋掉header()功能,它顯示在進度條(耶)的錯誤,但把它當作successed,這不是我有一個錯誤來對待它。用header()刪除了js腳本,轉到uploadSuccess而不是uploadError
該文件是非常醜陋的,我什麼都沒有找到。

回答

3

刪除標題,然後在echo $message之後添加exit(0)。我認爲這將解決這個問題。