Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Tworzenie obrazu za pomocą GD, Błąd nagłówka - headers already sent
tmgryf
post
Post #1





Grupa: Zarejestrowani
Postów: 79
Pomógł: 1
Dołączył: 14.02.2009

Ostrzeżenie: (0%)
-----


CODE
header('Content-type: image/jpeg');
// The file you are resizing
$file = './images/logo.jpg';

//This will set our output to 45% of the original size
$size = 0.45;

// This sets it to a .jpg, but you can change this to png or gif


// Setting the resize parameters
list($width, $height) = getimagesize($file);
$modwidth = $width * $size;
$modheight = $height * $size;

// Creating the Canvas
$tn= imagecreatetruecolor($modwidth, $modheight);
$source = imagecreatefromjpeg($file);

// Resizing our image to fit the canvas
imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);

// Outputs a jpg image, you could change this to gif or png if needed
imagejpeg($tn);
?>


Wywala błąd:
Warning: Cannot modify header information - headers already sent by (output started at /home/tmg/domains/pmg.izfree.com/public_html/image.php:1) in /home/tmg/domains/pmg.izfree.com/public_html/image.php on line 2

Przecież nagłówek wysyłam w pierwszej linii kodu - plik wywołuje bezpośrednio - serwer/image.php więc co jest nie tak?
Firebug twierdzi że dostaje: Content-Type text/html

Sam sobie odpowiem..... zmiana kodowania z utf8 na utf8 without bom rozwiazala problem (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif) (IMG:http://forum.php.pl/style_emoticons/default/party.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
jareeny
post
Post #2





Grupa: Zarejestrowani
Postów: 226
Pomógł: 23
Dołączył: 2.10.2007
Skąd: Słupsk

Ostrzeżenie: (0%)
-----


To może być nawet spacja, byle co. wstaw w pierwszej linii ob_start() a na końcu ob_end_flush().
Go to the top of the page
+Quote Post
maly_swd
post
Post #3





Grupa: Zarejestrowani
Postów: 744
Pomógł: 118
Dołączył: 14.02.2009
Skąd: poziome

Ostrzeżenie: (0%)
-----


a nie masz pliku w UTF BOM?
http://pl.wikipedia.org/wiki/BOM

ktory to ma na poczatku 3 bajty i czesta sa z tym problemy;)

zapisz pusty plik i zobacz jaka ma wielkosc, jak 3 bajty to masz BOMa
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 17:44