Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Pomocy! Gdzie jest blad?
JamalBIG
post 24.01.2008, 17:31:37
Post #1





Grupa: Zarejestrowani
Postów: 496
Pomógł: 1
Dołączył: 16.01.2008
Skąd: Świnoujście

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


Witam

Oto kod ktory utworzylem ale nie wiem dlaczego, pomniejszany plik nie chce sie zapisac w sciezce podanej przy funkcji move_upload_file...
<?php
// The file
$filename = 'test.jpg';

// Set a maximum height and width
$width = 200;
$height = 200;

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

$ratio_orig = $width_orig/$height_orig;

if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

// Output
imagejpeg($image_p, null, 100);
//imagejpeg($image_p, null, 100);
imagedestroy($image_p);
imagedestroy ($image);
move_upload_file ("upload/test.jpg");
?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
Garrappachc
post 24.01.2008, 17:37:21
Post #2





Grupa: Zarejestrowani
Postów: 76
Pomógł: 2
Dołączył: 15.11.2007
Skąd: Kraków

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


move_uploaded_file


--------------------


CPU | GPU | RAM | HDD | OS
Go to the top of the page
+Quote Post
JamalBIG
post 24.01.2008, 17:55:33
Post #3





Grupa: Zarejestrowani
Postów: 496
Pomógł: 1
Dołączył: 16.01.2008
Skąd: Świnoujście

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


Teraz tak wyglada:

<?php
// The file
$filename = 'test.jpg';

// Set a maximum height and width
$width = 200;
$height = 200;

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

$ratio_orig = $width_orig/$height_orig;

if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

// Output
imagejpeg($image_p, null, 100);
//imagejpeg($image_p, null, 100);
imagedestroy($image_p);
imagedestroy ($image);
move_uploaded_file ($filename, "upload/test.jpg");
?>

Ale nadal plik nie chce sie zapisac w okreslonej lokalizacji "upload/test.jpg"...
Go to the top of the page
+Quote Post
qrees
post 24.01.2008, 18:56:16
Post #4





Grupa: Zarejestrowani
Postów: 275
Pomógł: 44
Dołączył: 23.11.2007

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


1. Używaj bbcode, bo nic nie widać...
2. move_uploaded_file zapisuje plik który został wysłany na serwer, a nie plik, który został wysłany przez serwer. jako 2 parametr do imagejpeg podajesz NULL, a chcesz zapisać plik na dysku... Musisz podać ścieżkę gdzie chcesz ten plik zapisać...

Ten post edytował qrees 24.01.2008, 18:56:37
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 04:25