denzil_cactus has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
I have used MIME::Base64::decode_base64 for decding the pdf image and insert into the database so that it can be displayed on web but it still not showing the pdf properly. Is the logic correct that I used?
$cContent = MIME::Base64::decode_base64($cFile);
and I am inserting $cContent to a database type mediumblob in mysql but it does not work on web. please help

Replies are listed 'Best First'.
Re: Problem in MIME::Base64::decode_base64
by gmargo (Hermit) on Nov 05, 2009 at 13:08 UTC

    Hopefully $cFile is not a filename, as the name implies. As long as $cFile is a base 64 encoded string, it should work.

Re: Problem in MIME::Base64::decode_base64
by scorpio17 (Canon) on Nov 05, 2009 at 14:26 UTC

    If you're trying to write a cgi script that will output PDF, make sure to set the proper MIME type - else the client/browser will probably try to interpret it as HTML.

    BTW - putting PDF (or any large binary) files in a database sounds like a really bad idea, IMO. I'd suggest storing the files somewhere on the server, outside of the web root dir. Only store the path to each file in the DB. Then when your cgi script needs a file, rather than pull the file out of the DB, pull the path out of the DB, then read it from that path and write it to the browser.