title: Convert Base64 string to an image file?
body: <p>I am trying to convert my base64 image string to an image file. This is my Base64 string:</p>
  
  <p><a href="http://pastebin.com/ENkTrGNG">http://pastebin.com/ENkTrGNG</a></p>
  
  <p>Using following code to convert it into an image file:</p>
  
  <pre><code>function base64_to_jpeg( $base64_string, $output_file ) {
      $ifp = fopen( $output_file, "wb" ); 
      fwrite( $ifp, base64_decode( $base64_string) ); 
      fclose( $ifp ); 
      return( $output_file ); 
  }
  
  $image = base64_to_jpeg( $my_base64_string, 'tmp.jpg' );
  </code></pre>
  
  <p>But I am getting an error of <code>invalid image</code>, whats wrong here?</p>