'ello all.
I am trying to assist someone in getting this script working.
For some reason, the script is dumping the data to the screen instead of the file specified. Could anyone shed some light onto this for me?
To be honest, I'm not really sure what it does, but it works other than the data being dumped to the screen.
TIA!
<?php
//error_reporting(0);
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];
$w = 300;
$h = 300;
$img = imagecreatetruecolor($w, $h);
imagefill($img, 0, 0, 0xFFFFFF);
$rows = 0;
$cols = 0;
for($rows = 0; $rows < $h; $rows++){
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
$value = $c_row[$cols];
if($value != ""){
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
$test = imagecolorallocate($img, $r, $g, $b);
imagesetpixel($img, $cols, $rows, $test);
}
}
}
#header("Content-type:image/jpeg");
#imagejpeg($img, "", 95);
header("Content-type:text/html");
$fileName = time(0).".jpg";
$data = imagejpeg($img, "", 95);
$handle = fopen($fileName, "wb");
if(fwrite($handle, $data)) echo $fileName.' written.';
fclose($handle);
?>