嘿,我有以下脚本,基本上是一个闪存文件向它发送一些数据,它创建一个图像,然后为用户打开一个另存为对话框,以便他们可以将图像保存到系统中。问题来了,如何我还要将图像保存到我的服务器吗?
<?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 );
?>
帮助将不胜感激!
imagejpeg( $image, $filename );
将图像保存到$filename
。所以本质上可以做
imagejpeg( $image, $filename );
imagedestroy( $image );
readfile( $filename );
而不是仅仅打电话
imagejpeg( $image );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)