title: How to base64-decode large files in PHP
body: <p>My PHP web application has an API that can recieve reasonably large files (up to 32 MB) which are base64 encoded. The goal is to write these files somewhere on my filesystem. Decoded of course. What would be the least resource intensive way of doing this?</p>
  
  <p><strong>Edit:</strong> Recieving the files through an API means that I have a 32MB string in my PHP app, not a 32 MB source file somewhere on disk. I need to get that string decoded an onto the filesystem.</p>
  
  <p>Using PHP's own base64_decode() isn't cutting it because it uses a <i>lot</i> of memory so I keep running into PHP's memory limit (I know, I could raise that limit but I don't feel good about allowing PHP to use 256MB or so per process).</p>
  
  <p>Any other options? Could I do it manually? Or write the file to disk encoded and call some external command? Any thought?</p>