How do I write an image, along with other data, to my database using php and mysql -


hello: have web form submits data db. able create signature image , save within directory. want save/store signature image in mysql db along record can call later.

written in codeigniter 2.0

here model , controller.

public function sig_to_img()         {             if($_post){                 require_once apppath.'signature-to-image.php';                  $json = $_post['output'];                  $img = sigjsontoimage($json);              imagepng($img, 'signature.png');              imagedestroy($img);              $form = $this->input->post();             var_dump($form);                 $this->coapp_mdl->insert_signature($form);             }         }  public function insert_signature($data)         {           $sig_hash = sha1($data['output']);           $created = time();           $ip = $_server['remote_addr'];            $data = array(             'first_name' => $data['fname'],             'last_name' => $data['lname'],               'signator' => $data['name'],               'signature' => $data['output'],               'sig_hash' => $sig_hash,               'ip' => $ip,               'created' => $created           );              return $this->db->insert('signatures', $data);         } 

i found function below on php.net apparently doing wrong or various things wrong. know how accomplish functionality?

$imagefile = "changethistogourimage.gif";  $image = imagecreatefromgif($imagefile); ob_start(); imagepng($image); $imagevariable = ob_get_contents(); ob_end_clean(); 

got - curious here changes controller:

public function sig_to_img()         {             if($_post){                 require_once apppath.'signature-to-image.php';                  $json = $_post['output'];                  $img = sigjsontoimage($json);  // save file             $file_name = trim(str_replace(" ","_",$_post['name']));//name used filename             imagepng($img, apppath."../images/signatures/".$file_name.'.png');             $sig_name = $file_name.'.png'; //pass model  // destroy image in memory when complete             imagedestroy($img);              $form = $this->input->post();             var_dump($form);                      $this->coapp_mdl->insert_signature($form, $sig_name);             }          } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -