title: php base64 decode function is unable to decode base64 image string
body: <p>since <code>ie7</code> &amp; <code>ie8</code> are unable to decode base64 image string by default, i was looking for an alternative way to do it. after googleing about the issue i have found a good tutorial at <a href="http://dean.edwards.name/weblog/2005/06/base64-ie/" rel="nofollow">http://dean.edwards.name/weblog/2005/06/base64-ie/</a> .</p>
  
  <p>as far as i understand the process of decode consists of two short scripts which are as following:</p>
  
  <p>A. <strong>php base64 decode function</strong> </p>
  
  <p>named as <code>base64.php</code> as guided by the author</p>
  
  <pre><code>&lt;?php
  $data = split(";", $_SERVER["QUERY_STRING"]);
  $type = $data[0];
  $data = split(",", $data[1]);
  header("Content-type: ".$type);
  echo base64_decode($data[1]);
  ?&gt;
  </code></pre>
  
  <p>B. <strong>javascript</strong> </p>
  
  <p>which shall be inserted within the head tag of the page where base64 image string shall be embedded and which finally shall pass the image string to <code>base64.php</code> for processing &amp; decoding.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  // a regular expression to test for Base64 data
  var BASE64_DATA = /^data:.*;base64/i;
  // path to the PHP module that will decode the encoded data
  var base64Path = "base64.php";
  function fixBase64(img) {
    // check the image source
    if (BASE64_DATA.png(img.src)) {
      // pass the data to the PHP routine
      img.src = base64Path + "?" + img.src.slice(5);
    }
  };
  // fix images on page load
  onload = function() {
    for (var i = 0; i &lt; document.images.length; i++) {
      fixBase64(document.images[i]);
    }
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>unfortunately php base64 decode function is unable to decode the image string  to <code>ie7</code> &amp; <code>ie8</code> in my case.</p>
  
  <p>my doc type is <code>DTD XHTML 1.0 Transitional</code> &amp; <code>charset=utf-8</code>. </p>
  
  <p>any idea what's going wrong here? </p>
  
  <p><strong>demo links:</strong></p>
  
  <p>base64-string-without-php-decoder: <a href="http://silentpond.eu5.org/base64-string-without-php-decoder.php" rel="nofollow">http://silentpond.eu5.org/base64-string-without-php-decoder.php</a></p>
  
  <p>base64-string-with-php-decoder: <a href="http://silentpond.eu5.org/base64-string-with-php-decoder.php" rel="nofollow">http://silentpond.eu5.org/base64-string-with-php-decoder.php</a></p>
  
  <p>thanks,</p>