Base64 strings -> Gzip -> Decompressed file

Hi guys,

I have a database where files are stored as base64 chunks.
I’d like to have the possibility of saving down a specific file from a PHP page, but I just can’t get it right.

The Gzip file is created with the Testfile.pdf in it, but when opening the pdf it’s broken.

What am I missing? Here’s my code:

[php]$Base64Chunks = "H4sIAAAAAAAAAIx7A3QlbZd1bJudGzu5sTq2bXds………………”;
$Filename = “Testfile.pdf.gzip”;
$data = utf8_encode(base64_decode($Base64Chunks));
$gzdata = gzencode($data, 9);
$fp = fopen($Filename, “wb”);
fwrite($fp, $gzdata);
fclose($fp);[/php]

Thanks in advance!

I don’t have the ability to walk thru it currently, but is the column size big enough to prevent truncation?

Thanks for your reply! Yeah and I’ve confirmed the Base64 string is intact. Any ideas?

Sponsor our Newsletter | Privacy Policy | Terms of Service