Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Problem z imagecreatefromjpeg
Forum PHP.pl > Forum > Przedszkole
MONII28
Mam błąd Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\program files\easyphp1-8\www\image.php on line 54
  1. <?php
  2.  
  3. $link = mysql_connect( "localhost", "xxx", "xxx")
  4. or die("Nie mogę się połączyć: " . mysql_error());
  5. mysql_select_db("meble",$link)
  6. or die (mysql_error());
  7.  
  8. $opis = $_POST['opis'];
  9. $zdjecie = $_FILES['zdjecie']['name'];
  10. $today = date("Y-m-d");
  11.  
  12. $ImageDir ="C:/Program Files/EasyPHP1-8/www/zdjecia/";
  13. $ImageThumb = $ImageDir . "thumbs/";
  14. $ImageName = $ImageDir . $zdjecie;
  15. if(move_uploaded_file($_FILES['zdjecie']['tmp_name'], $ImageName)){
  16. list($width, $height, $type, $attr) = getimagesize($ImageName);
  17. if ($type > 3) {
  18. echo "Przesłany obraz nie jest w formacie GIF , JPG lub PNG.<br>";
  19. } else {
  20. $insert = "INSERT INTO realizacje
  21. (opis, zdjecie, data)
  22. VALUES
  23. ('$opis', '$zdjecie', '$today')";
  24. $insertresults = mysql_query($insert)
  25. or die(mysql_error());
  26. $lastpicid = mysql_insert_id();
  27. $newfilename = $ImageDir .$lastpicid . ".jpg";
  28. if ($type == 2){
  29. rename($ImageName, $newfilename);
  30. } else {
  31. if ($type == 1) {
  32. $image_old = imagecreatefromgif($ImageName);
  33. } elseif ($type == 3) {
  34. $image_old = imagecreatefrompng($ImageName);
  35. }
  36. $image_jpg = imagecreatetruecolor($width, $height);
  37. imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,
  38. $width, $height, $width, $height);
  39. imagejpeg($image_jpg, $newfilename);
  40. imagedestroy($image_old);
  41. imagedestroy($image_jpg);
  42.  
  43. }
  44. $newthumbname = $ImageThumb . $lastpicid . ".jpg";
  45. $thumb_width = $width * 0.10;
  46. $thumb_height = $height * 0.10;
  47. $largeimage = imagecreatefromjpeg($newfilename);
  48. $thumb =imagecreatetruecolor($thumb_width, $thumb_height);
  49. imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0,
  50. $thumb_width, $thumb_height, $thumb_width, $thumb_height);
  51. imagejpeg($thumb, $newthumbname);
  52. imagedestroy($largeimage);
  53. imagedestroy($thumb);
  54. $url= "location: showimage.php?id=" . $lastpicid;
  55. header($url);
  56. }
  57. }
  58.  
  59.  
  60.  
  61.  
  62. ?>


Dlaczego?
Xniver
Na serwerze nie ma biblioteki GD2
MONII28
Jak to zmienić aby działało?
Hazel
Na początek w pliku php.ini odkomentuj linię ;extension=php_gd2.dll (usuń z niej średnik na początku).
-MONII28-
Wysłałam stronę na serwer freens.pl. Wcześniej na lokalnym serwerze działało mi zapisanie zdjęcia do pliku a teraz nie działa podejrzewam że źle wpisuje ścieżkę do pliku na serwerze freens
  1. <?php
  2. $ImageDir ="/public_html/zdjecia/";
  3. ?>
Jak mam wpisać , co mam źle. http://www.meblenawymiar.freens.pl/
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.