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

Roel Mulder roel.mulder at gmail.com
Fri May 6 09:28:49 CDT 2016


Thanks for the quick reply Nadeem.

fwrite($file, base64_decode($row['file_content']));

Doesn't do the trick either. Now the files are all 1kB and contain just the
one character <.
They use a dedicated Windows application to add and retrieve documents.
That source/application code is not available.

If any of you would like/dare to take a look at a document, then please
drop me an email, as I wont send files to the list.

On 6 May 2016 at 12:45, Nadeem Hosenbokus <nadeem at nadeemh.com> wrote:

> My first guess would be to decode Base64 values.
>
> It's fairly normal to encode data with Base64 when inserting into a
> database.
>
> 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.
>
> Thanks,
>
> Nadeem Hosenbokus
> (230) 5766 9169
> www.nadeemh.com
> http://mu.linkedin.com/in/nadeemhosenbokus
>
>
> -----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']);
>   fclose($file);
>   touch('/var/www/vhosts/path/'.$row['file_name'],
> strtotime($row['file_date']));
> }
>
> 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
> conditions?
> Cheers, Roel
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester and archives
> of thelist go to: http://lists.evolt.org Workers of the Web, evolt !
>
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> 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