title: Image upload from iPhone strips exif data
body: <p>I've built a website which allows image uploading and once an image is uploaded , some specific information about the photo is displayed.
  Uploading pictures from computers works just fine , the problem comes up when I'm trying to upload an image from a smartphone. The upload success but it seems like a major part of the data that is displayed when uploading from computer is now missing.</p>
  
  <p>This code section is the one that actually retrieves and display the data :</p>
  
  <pre><code>$location = $_FILES["pic"]["tmp_name"];
  $data = exif_read_data($location);
  var_dump($data);
  </code></pre>
  
  <p>the <code>var_dump($data)</code> actually dumps different data in computers and smartphones.</p>
  
  <h3>Apparently it works just fine with Android smartphones, the problem only comes up when I try to upload images from iPhone.</h3>
  
  <p>For example, <code>var_dump</code> from <strong>computer</strong> upload :</p>
  
  <pre><code>array(49) { 
      ["FileName"]=&gt; string(10) "php2D4.tmp" 
      ["FileDateTime"]=&gt; int(1367318152) 
      ["FileSize"]=&gt; int(30357) 
      ["FileType"]=&gt; int(2) 
      ["MimeType"]=&gt; string(10) "image/jpeg" 
      ["SectionsFound"]=&gt; string(24) "ANY_TAG, IFD0, EXIF, GPS" 
      ["COMPUTED"]=&gt; array(6) { 
          ["html"]=&gt; string(24) "width="320" height="240""  
          ["Height"]=&gt; int(240)  
          ["Width"]=&gt; int(320)  
          ["IsColor"]=&gt; int(1)  
          ["ByteOrderMotorola"]=&gt; int(1)  
          ["ApertureFNumber"]=&gt; string(5) "f/2.8"  
      }  
      ["Make"]=&gt; string(5) "Apple"  
      ["Model"]=&gt; string(8) "iPhone 4"  
      ["Orientation"]=&gt; int(3)  
      ["XResolution"]=&gt; string(4) "72/1"  
      ["YResolution"]=&gt; string(4) "72/1"  
      ["ResolutionUnit"]=&gt; int(2)  
      ["Software"]=&gt; string(5) "6.1.3"  
      ["DateTime"]=&gt; string(19) "2013:04:26 23:57:43"  
      ["YCbCrPositioning"]=&gt; int(1)  
      ["Exif_IFD_Pointer"]=&gt; int(204)  
      ["GPS_IFD_Pointer"]=&gt; int(594)  
      ["ExposureTime"]=&gt; string(4) "1/15"  
      ["FNumber"]=&gt; string(4) "14/5"  
      ["ExposureProgram"]=&gt; int(2)  
      ["ISOSpeedRatings"]=&gt; int(1000)  
      ["ExifVersion"]=&gt; string(4) "0221"  
      ["DateTimeOriginal"]=&gt; string(19) "2013:04:26 23:57:43"  
      ["DateTimeDigitized"]=&gt; string(19) "2013:04:26 23:57:43"  
      ["ComponentsConfiguration"]=&gt; string(4) ""  
      ["ShutterSpeedValue"]=&gt; string(9) "4889/1250"  
      ["ApertureValue"]=&gt; string(9) "4281/1441"  
      ["BrightnessValue"]=&gt; string(10) "-3581/1451"  
      ["MeteringMode"]=&gt; int(5)  
      ["Flash"]=&gt; int(24)  
      ["FocalLength"]=&gt; string(5) "77/20"  
      ["SubjectLocation"]=&gt; array(4) {  
          [0]=&gt; int(1295) 
          [1]=&gt; int(967) 
          [2]=&gt; int(699) 
          [3]=&gt; int(696) 
      } 
      ["FlashPixVersion"]=&gt; string(4) "0100" 
      ["ColorSpace"]=&gt; int(1) 
      ["ExifImageWidth"]=&gt; int(2592) 
      ["ExifImageLength"]=&gt; int(1936) 
      ["SensingMethod"]=&gt; int(2) 
      ["ExposureMode"]=&gt; int(0) 
      ["WhiteBalance"]=&gt; int(0) 
      ["FocalLengthIn35mmFilm"]=&gt; int(35) 
      ["SceneCaptureType"]=&gt; int(0) 
      ["GPSLatitudeRef"]=&gt; string(1) "N" 
      ["GPSLatitude"]=&gt; array(3) { 
          [0]=&gt; string(4) "31/1" 
          [1]=&gt; string(8) "5854/100" 
          [2]=&gt; string(3) "0/1" 
      } 
      ["GPSLongitudeRef"]=&gt; string(1) "E" 
      ["GPSLongitude"]=&gt; array(3) { 
          [0]=&gt; string(4) "34/1" 
          [1]=&gt; string(8) "4684/100" 
          [2]=&gt; string(3) "0/1" 
      } 
      ["GPSTimeStamp"]=&gt; array(3) { 
          [0]=&gt; string(4) "20/1" 
          [1]=&gt; string(4) "57/1" 
          [2]=&gt; string(8) "4272/100" 
      } 
      ["GPSImgDirectionRef"]=&gt; string(1) "T" 
      ["GPSImgDirection"]=&gt; string(9) "48089/465" 
  }
  </code></pre>
  
  <p><code>var_dump</code> from <strong>smartphone</strong> upload:</p>
  
  <pre><code>array(12) { 
      ["FileName"]=&gt; string(9) "phpSzwfPw" 
      ["FileDateTime"]=&gt; int(1367318054) 
      ["FileSize"]=&gt; int(1778041) 
      ["FileType"]=&gt; int(2) 
      ["MimeType"]=&gt; string(10) "image/jpeg" 
      ["SectionsFound"]=&gt; string(19) "ANY_TAG, IFD0, EXIF" 
      ["COMPUTED"]=&gt; array(5) { 
          ["html"]=&gt; string(26) "width="2592" height="1936"" 
          ["Height"]=&gt; int(1936) 
          ["Width"]=&gt; int(2592) 
          ["IsColor"]=&gt; int(1) 
          ["ByteOrderMotorola"]=&gt; int(1) 
      } 
      ["Orientation"]=&gt; int(3) 
      ["Exif_IFD_Pointer"]=&gt; int(38) 
      ["ColorSpace"]=&gt; int(1) 
      ["ExifImageWidth"]=&gt; int(2592) 
      ["ExifImageLength"]=&gt; int(1936) 
  }
  </code></pre>
  
  <p>Here's the <strong>computer</strong> <code>var_dump($_FILES)</code> :</p>
  
  <pre><code>    array(1) 
  { ["pic"]=&gt; array(5) 
  { ["name"]=&gt; string(18) leaf2.JPG" 
  ["type"]=&gt; string(10) "image/jpeg" 
  ["tmp_name"]=&gt; string(14) "/tmp/phpzeDUs9"
   ["error"]=&gt; int(0)
   ["size"]=&gt; int(46439) } }
  </code></pre>
  
  <p>Here's the <strong>iPhone</strong> results <code>var_dump($_FILES)</code> : </p>
  
  <pre><code>    array(1) { ["pic"]=&gt; array(5) 
  { ["name"]=&gt; string(9) "image.jpg" 
  ["type"]=&gt; string(10) "image/jpeg" 
  ["tmp_name"]=&gt; string(14) "/tmp/phplPUZky" 
  ["error"]=&gt; int(0) ["size"]=&gt; int(1455577) } } 
  </code></pre>
  
  <p><strong>EDIT :  Here is the uploading form HTML code:</strong> </p>
  
  <pre><code>     &lt;form action="results.php" id="upload-image" method="post" enctype="multipart/form-data"&gt;
           &lt;div class="fileupload fileupload-new" data-provides="fileupload"&gt;
            &lt;div class="fileupload-preview thumbnail" style="width: 200px; height: 150px;"&gt;&lt;/div&gt;
            &lt;div&gt;
              &lt;span class="btn btn-file"&gt;&lt;span class="fileupload-new"&gt;Select image&lt;/span&gt;&lt;span class="fileupload-exists"&gt;Change&lt;/span&gt;&lt;input type="file" name="pic" id="pic" accept="image/*"/&gt;&lt;/span&gt;
              &lt;a href="#" class="btn fileupload-exists" data-dismiss="fileupload"&gt;Remove&lt;/a&gt;
              &lt;button type="submit" class="btn"&gt;Upload&lt;/button&gt;
              &lt;/br&gt;
              &lt;span class="upload-error"&gt;&lt;/span&gt;
            &lt;/div&gt;
       &lt;/form&gt;
  </code></pre>
  
  <p>What might cause it?</p>