PHP rejects image upload in some cases, but I can't figure out why
<p>I have a process whereby I take a picture on a phone and upload it to a PHP script on my server.</p>

<p>It usually works, but *sometimes the phone takes a picture that has SOMETHING about it that the PHP doesn't like.  I have copied the image to my computer and attempted to upload it through a standard browser upload form but get the same error.</p>

<p>My question is, how do I find out what the PHP is not liking about the image? (it appears to be a perfectly legitimate JPG, just like all the others that DO work).</p>

<p>My PHP looks like this:</p>

<pre><code>if ( move_uploaded_file( $_FILES[ 'file' ][ 'tmp_name' ], $folder . $fileName1 ) ) {
  echo "SUCCESS";       
}
else{           
 "FAIL:";
  foreach (getallheaders() as $name =&gt; $value) {
           echo "|$name: $value| ";
  }
</code></pre>

<p>}</p>

<p>I'd like to print and save some error info about what is going wrong here, but am not sure how to introduce what, in effect, would be a catch block in PHP.</p>

<p>All help appreciated. </p>
