<?php
$Id = "3";
if(!isset($Id)) die("Need 'Id' parameter"); include("common.php");
if (! $link) die ("Couldn't connect to mySQL server"); $query = "SELECT filetype, bin_data FROM tbl_Files WHERE id_files='$Id';";
$bin_data = $query_data[bin_data];
Header("Content-type: $filetype"); //echo $bin_data; //TU JEST OK WYSWIETLA OBRAZEM
$filename = imagecreatefromstring($bin_data);
$percent = 0.5;
$new_width = $width * $percent;
$new_height = $height * $percent;
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($image_p, null, 100);
imagedestroy($image_p);
?>
Niestety nic nie wyświetla, podstawiając pod $filename nazwę pliku na serwerze to działa. Jednak tworząc obraz za pomocą imagecreatefromstring($bin_data) nie działa. Z manuala dorwałem gotowca, który tez nie działa!!
<?php
require("dbconfig.inc");
$id = $_GET['id'];
if($id) {
$query = "select filetype, image from pictures where id = $id";
Header( "Content-type: $type");
$size = 150; // new image width
$src = imagecreatefromstring($data);
$width = imagesx($src);
$height = imagesy($src);
$aspect_ratio = $height/$width;
if ($width <= $size) {
$new_w = $width;
$new_h = $height;
} else {
$new_w = $size;
$new_h = abs($new_w * $aspect_ratio); }
$img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);
// determine image type and send it to the client
if ($type == "image/pjpeg") {
imagejpeg($img);
} else if ($type == "image/x-png") {
imagepng($img);
} else if ($type == "image/gif") {
imagegif($img);
}
imagedestroy($img);
};
?>
Czy to możliwe, że mam jakieś ograniczenia po stronie serwera?