title: jQuery-File-Upload (blueimp) - how do I access the error value both in JS end and PHP
body: <p>How do I test if the file uploaded has returned an error using blueimps file uploader.</p>
  
  <p>The uploader only allows a single file upload (must be an image).</p>
  
  <p>I have the following js code</p>
  
  <pre><code>&lt;script&gt;
  $(function () {
      $('#fileupload').fileupload({
      dataType: 'json',
      singleFileUploads: true ,
      submit: function (e, data) {
         $('#upload_overlay').fadeIn(300);
      },
      done: function (e, data) {
  
  
  
        if(typeof data.files.error == "undefined"){
          $('#err_succ_msg').html('Photo successfully updated.').css('background-color','#B1DD8B').show(1);
          $('#upload_overlay').fadeOut(300);
        }
        else{
  
          $('#err_succ_msg').html('Photo update failed. Please try again.').css('background-color','#F76151').show(1);
          $('#upload_overlay').fadeOut(300);
        }
  
      },
  
      fail: function (e, data) {
        $('#err_succ_msg').html('Photo update failed. Please try again.').css('background-color','#F76151').show(1);
        $('#upload_overlay').fadeOut(300);
      }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>In the "done" function I'm trying to find out if there is a error so I can show the correct message to the user.</p>
  
  <p>I've tried "alerting" out data.result[0].error and data.files[data.index].error but it either comes out blank or has a "data.result[0]" is undefined.</p>
  
  <p>Mostly from this question here: <a href="https://stackoverflow.com/questions/12506459/blueimp-jquery-file-upload-how-do-i-get-the-error-message-if-the-file-type-was">blueImp/jquery file upload - How do I get the error message if the file type was not accepted?</a></p>
  
  <p>also on the PHP side of things how do I check if there is an error. For example the PHP index file has this:</p>
  
  <pre><code>require('UploadHandler.php');
  $upload_handler = new UploadHandler();
  </code></pre>
  
  <p>What do I need to figure out if there is an error so I do some processing on the server side?</p>