Saving image to server with php

Posted by salmon on Stack Overflow See other posts from Stack Overflow or by salmon
Published on 2010-03-12T09:40:34Z Indexed on 2010/03/12 9:47 UTC
Read the original article Hit count: 171

Filed under:
|
|
|

Hey i have the following script, basicaly a flash file sends it some data and it creates a image and then opens a save as dialog box for the user so that they can save the image to there system.Here the problem comes in, how would i go about also saving the image to my server?

<?php

$to = $_POST['to'];
$from = $_POST['from'];
$fname = $_POST['fname'];
$send = $_POST['send'];

$data = explode(",", $_POST['img']);
$width = $_POST['width'];
$height = $_POST['height'];
$image=imagecreatetruecolor( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
    for($y=0; $y<=$height; $y++){
        $int = hexdec($data[$i++]);
        $color = ImageColorAllocate ($image, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
        imagesetpixel ( $image , $x , $y , $color );
    }
}
//Output image and clean
#header("Content-Disposition: attachment; filename=test.jpg" );
header("Content-type: image/jpeg");

ImageJPEG( $image );
imagedestroy( $image ); 
?>

Help would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about php

Related posts about server