FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » is mysqli_real_escape_string bullet proof with binary data?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: is mysqli_real_escape_string bullet proof with binary data? [message #182279 is a reply to message #182274] Sat, 27 July 2013 13:35 Go to previous messageGo to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
On 07/27/2013 05:31 AM, The Natural Philosopher wrote:
> The target is to create and store thumbnail PNG images in a Mysql table.
> Also any tips on actually getting the thumbnail data into a variable -
> which package is recommended? I've always used GD, but never been 100%
> happy with it
>

Well, you don't sat why you don't like GD but that is what I use (on
one of my sites) so here is what I do---

When writing *to* the database:
A) You have sql LOAD_FILE to store a file (filesystem) in the db.

I write the GD image resource to a tmp file and then store it using
LOAD_FILE.

imagepng($img, $destfile);
/* stuff */
$query = "UPDATE table SET img_data = LOAD_FILE('$destfile') WHERE ?"

B) ??


When retrieving *from* the db:
A) The binary data is in the result set such that:

header("Content-Type: image/png");
echo $result['image_data']

-or-

You can create a GD image resource by using:

$img = imagecreatefromstring($result['image_data']);
/* GD manipulations */
header("Content-Type: image/png");
imagepng($img);

either should output an image to the browser.

B) output_buffering lets you do some crazy stuff.


-or-

Take a look at the Imagick module for PHP (PECL).

http://www.php.net/manual/en/imagick.getimageblob.php
http://www.php.net/manual/en/imagick.readimageblob.php
http://www.php.net/manual/en/imagick.readimagefile.php

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Major trouble with PhpDocumentor
Next Topic: Education Path to become a PHP developer using free online courses
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 21:21:28 GMT 2024

Total time taken to generate the page: 0.05871 seconds