# Screenshot from Flash into MySQL database

**URL:** <https://forum.kirupa.com/t/screenshot-from-flash-into-mysql-database/318258>\
**Category:** programming\
**Created:** [January 14, 2011, 4:26pm UTC](https://forum.kirupa.com/t/screenshot-from-flash-into-mysql-database/318258 "2011-01-14T16:26:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Butters](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Butters](https://forum.kirupa.com/u/Butters)\
**Post date:** [January 14, 2011, 4:26pm UTC](https://forum.kirupa.com/t/screenshot-from-flash-into-mysql-database/318258/1 "2011-01-14T16:26:46Z")

</div>

Helloooo!

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:

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

	$string="";
	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 );
			$i++;
		}
	}
	$date = date('dmYgis');
	$rand = rand(0, 1000);
	$extension = '.jpg';
	header("Content-Type: image/jpeg");
	//show image. free memory
	imagejpeg($image,'',100);
	imagejpeg($image, $date.$rand.$extension,100); 
	imagedestroy( $image );	
?>

```

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

Thanks 🙂
