Merge Image save to mysql database without clicking anything

Mico Beldad
Mico Beldad used Ask the Experts™
on
Can anyone help me about my problem?
I have successfully merge a image but i dont know how to insert it into DB

the code is something like this
 <?php
      $logo = "SecurityBank.png";
      $white_image = "image_size.png";
      $targetfile = "Phobo_New_Image.png";

      $Whitebackground = imagecreatefrompng($white_image);
      $whitebgW = imagesx($Whitebackground)-300;
      $whitebgH = imagesy($Whitebackground);
                        
      $partnerlogo = imagecreatefrompng($logo);
      $partnerlogoW = imagesx($partnerlogo);
      $partnerlogoH = imagesy($partnerlogo);
                  
      $photoFrame = imagecreatetruecolor($whitebgW,$whitebgH);
        $destlogo_x = $whitebgW - $partnerlogoW;
      $destlogo_y = $whitebgH - $partnerlogoH;
                  
      imagecopyresampled($photoFrame, $Whitebackground, 0, 0, 0, 0, $whitebgW, $whitebgH,$whitebgW, $whitebgH);
      imagecopy($photoFrame, $partnerlogo, $destlogo_x-300, $destlogo_y-400, 0, 0, $partnerlogoW, $partnerlogoH);
      imagepng($photoFrame, $targetfile);
?>
<center><img src="<?php echo $targetfile ?>" width="700px" name="target" id="target" height="400px"></center>'

<!-----THE NEW MERGED IMAGE IS BEEN SHOWED
name="target" id="target"
--->

I want to insert it into datbase my setTimeout or anything that the file $target is save into to the database as blob or longtext.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
Commented:
Generally speaking, we do not put images into a database.  Instead, we store the image file (output from imagePNG() function) in the file server and put the URL of the image file into the database.  The reasons for this are many, but the most important reasons are performance and backup.  BLOB fields are often bad for both.  

But if you want to store the image file in the database, you can do that easily.  As soon as you write the $targetfile, you can read it back into a PHP variable with file_get_contents().  Then, escape the variable and INSERT it into the database table.

Information on the right ways to use MySQL is available in this article:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
Eddie ShipmanAll-around developer
Commented:
While I tend to agree with Ray that you shouldn't store images in a DB, if you really need to, I would convert them to using base64_encode() and them storing them in a Text column. Then to use them, you would have to base64_decode() them.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial