Screenshot from Flash into MySQL database


Basically i’ve built a little flash swf movie that allows the user to sign their name. It takes a screenshot of a specific movie clip, sends it out to a PHP file and then saves the file on the server.

I also need it to save the filename into the table where the data is so that it can be recalled at a later date. Here’s a breakdown to make it a bit more understandable:

  1. User is shown a page with information on from a row in the DB.
  2. User signs in the Flash box (with a pen, it’s like a paint tool), which sends the data to a 2nd PHP file.
  3. Whatever they signed in the flash box gets captured and saved as a jpg with a random number ($rand) + the date ($date) as the filename.

I’ve got it saving the screenshot from Flash…here’s the code from my PHP file:

if($_POST['iwidth'] == "" || $_POST['iwidth'] == "" || $_POST['iwidth'] == ""){
	echo "This file will only work when you call to it from the swf file, sorry!";

	if(!function_exists("imagecreate")) die("Sorry, you don't seem to have the right php version.");
	$data = explode(",", addslashes($_POST['img']));
	$width = addslashes($_POST['iwidth']);
	$height = addslashes($_POST['iheight']);
	$image=(function_exists("imagecreatetruecolor"))?imagecreatetruecolor( $width ,$height ):imagecreate( $width ,$height );
	imagefill($image, 0, 0, 0xFFFFFF);
	$i = 0;
	for($x=0; $x<=$width; $x++){
		for($y=0; $y<=$height; $y++){
			$r = hexdec("0X".substr( $data[$i] , 0 , 2 )); 
			$g = hexdec("0x".substr( $data[$i] , 2 , 2 )); 
			$b = hexdec("0x".substr( $data[$i] , 4 , 2 ));
			$color = imagecolorallocate($image, $r, $g, $b);
			imagesetpixel ( $image , $x , $y , $color );
	$date = date('dmYgis');
	$rand = rand(0, 1000);
	$extension = '.jpg';
	header("Content-Type: image/jpeg");
	//show image. free memory
	imagejpeg($image, $date.$rand.$extension,100); 
	imagedestroy( $image );	

How can I then save the filename to a cell in my database?

Thanks :slight_smile: