title: php decode base 64 very big file, not a string
body: <p>i have a system that saves files to the server harddrive in base 64 encoded after stripping them from email files. </p>
  
  <p>i would like to change the file to thier original format again, how can i do that in php?</p>
  
  <p>this is how i tried to save the files but that does not seem to create a valid files:</p>
  
  <pre><code>$start = $part['starting-pos-body'];
  $end = $part['ending-pos-body'];
  $len = $end-$start;
  $written = 0;
  $write = 2028;
  $body = '';
  while ($start &lt;= $end) {
   fseek($this-&gt;stream, $start, SEEK_SET);
   $my = fread($this-&gt;stream, $write);
   fwrite($temp_fp, base64_decode($my));
   $start += $write;
  }
  fclose($temp_fp);
  </code></pre>