[thelist] Extracting (compressed?) files from a MySQL database

Nadeem Hosenbokus nadeem at nadeemh.com
Fri May 6 05:45:38 CDT 2016

My first guess would be to decode Base64 values.

It's fairly normal to encode data with Base64 when inserting into a

If that doesn't work then I would ask for the original application code and
see what was done to the data before it was inserted into the database.


Nadeem Hosenbokus
(230) 5766 9169

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Roel Mulder
Sent: 06 May 2016 13:47
To: thelist at lists.evolt.org
Subject: [thelist] Extracting (compressed?) files from a MySQL database

Hi all,
The following challenge is facing me. A client requested me to help get his
files out of a MySQL database. The developer of their system is gone,
history being what it is.

I'm facing 26268 records with a total 1.8GB filesize in MySQL.
What i did in PHP: query the file_content (MEDIUMBLOB), file_name,
file_date, LIMIT 10.

while ($row = mysql_fetch_array($result)) {
  $file = fopen('/var/www/vhosts/path/'.$row['file_name'], 'w+');
  fwrite($file, $row['file_content']);

This gives me the files (.doc .docx .pdf .msg), however I can't open them
with their default programs. Opening them in a text editor does show code
and fragments of text.
Could the files be compressed prior to storing in MySQL?
  fwrite($file, gzdeflate($row['file_content']));

Now I can open them with their default program, to see many paged documents
with unreadable text fragments.

Does anyone have suggestions on how to extract them files to usable
Cheers, Roel

* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 

More information about the thelist mailing list