title: Errors handling with swfupload
body: <p>I don't figure out to do this. I started with a sample found on the download package and edited for my needs.
  I made an extension validation in the php server file script, so if the extension isn't in whitelist the script exits with an error. 
  I don't know how to get custom message works.</p>
  
  <p>There is the php function </p>
  
  <pre><code>function HandleError($message) {
      header("HTTP/1.1 500 Internal Server Error");
      echo $message;
  }
  </code></pre>
  
  <p>But this return only 500 instead of $message!  This is js <code>uploadError()</code></p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>If I comment out the <code>header()</code> function, it display the error in the progress bar (yay), but treat it like successed, and it's not I have to treat it with an error. With <code>header()</code> removed the js script go to <code>uploadSuccess</code> instead <code>uploadError</code>.<br>
  The documentation is really ugly and I don't find anything else.</p>