472,145 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

How to save image PHP

I tried to convert a movie (SWF) to Jpeg using getpixel then the jpeg image will be pass to show.php.

The show.php will be pop out in a new tab with the SWF converted already into a JPEG.

I want to save that image into MySql but i failed to insert it correctly.

Here is the Show.php code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $data = explode(",", $_POST['img']);
  3.     $width = $_POST['width'];
  4.     $height = $_POST['height'];
  5.     $image=imagecreatetruecolor( $width ,$height );
  6.     $background = imagecolorallocate( $image ,0 , 0 , 0 );
  7.     //Copy pixels
  9.     $i = 0;
  10.     for($x=0; $x<=$width; $x++){
  11.         for($y=0; $y<=$height; $y++){
  12.             $int = hexdec($data[$i++]);
  13.             $color = ImageColorAllocate ($image, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
  14.             imagesetpixel ( $image , $x , $y , $color );
  15.         }
  16.     }
  17.     //Output image and clean
  18.     header( "Content-type: image" );
  19.     ImageJPEG( $image );
  20.         imagedestroy( $image );
  23. ?>
Can anyone help me how can i pass the $image to MySql database?
Im also planning to echo the stored image for later use.

Im still a newbie in PHP. Help and suggestions are really appreciated.

Thank you. God Bless.
Mar 18 '10 #1
3 3997
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Mar 19 '10 #2
Im sorry about that. I got carried away by my problem forgot to be aware of forum tags. I'll edit it. Thanks

Sir do you have any idea how to pass the $image to the database?
Mar 19 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by George | last post: by
9 posts views Thread by Mark Johnson | last post: by
1 post views Thread by Sam Jost | last post: by
1 post views Thread by Hardy Wang | last post: by
2 posts views Thread by Ada | last post: by
1 post views Thread by liuliuliu | last post: by
1 post views Thread by Stedak | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.