Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z zapisem obrazu i miniatury do roznych katalogow.
pracz
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 7.01.2011

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


Witam! Mam kod do tworzenia obrazu i jego miniatury z uploadowanego zdjecia:
  1.  
  2. $foto_tmp = $_FILES['userfoto']['tmp_name'];
  3. $foto_nazwa = $_FILES['userfoto']['name'];
  4. $foto_rozmiar = $_FILES['userfoto']['size'];
  5.  
  6. if(is_uploaded_file($foto_tmp))
  7. {
  8.  
  9. list($width_src,$height_src) = getimagesize($foto_tmp);
  10.  
  11.  
  12. /*++++++Wylicza wysokosc i szerokosc nowego obrazu+++++*/
  13.  
  14. if ( $width_src < $height_src )
  15. { $nheight = 350;
  16. $nheight_s= 96;
  17.  
  18. $nwidth = $width_src*$nheight/$height_src;
  19. $nwidth_s = $width_src*$nheight_s/$height_src;
  20. }
  21. elseif( $width_src > $height_src )
  22. { $nwidth = 400;
  23. $nwidth_s = 96;
  24.  
  25. $nheight = $nwidth/$width_src*$height_src;
  26. $nheight_s = $nwidth_s/$width_src*$height_src;
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. $dst_img=imagecreatetruecolor($nwidth,$nheight);
  34. $dst_thumb=imagecreatetruecolor($nwidth_s,$nheight_s);
  35.  
  36. $src_img=ImageCreateFromJpeg($foto_tmp);
  37. $src_thumb=ImageCreateFromJpeg($foto_tmp);
  38.  
  39. $new=imagecopyresampled ($dst_img, $src_img, 0, 0, 0, 0, $nwidth, $nheight, $width_src,$height_src);
  40.  
  41.  
  42. $imagepath='photos';
  43. imagejpeg($dst_img, "7.jpeg", 100);
  44.  
  45. move_uploaded_file($new, $imagepath);
  46.  
  47.  
  48.  
  49.  
  50.  
  51. $new_s=imagecopyresampled ($dst_thumb, $src_thumb, 0, 0, 0, 0, $nwidth_s, $nheight_s, $width_src,$height_src);
  52.  
  53. $s_path='photos_s';
  54.  
  55. imagejpeg($dst_thumb, "8.jpeg", 100);
  56.  
  57.  
  58. if(move_uploaded_file($new_s, $s_path)){
  59. if(imagedestroy($foto_tmp))echo'ok';
  60. else echo'cos tu nie gra'; }
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67.  
  68. else echo'nie ma zdjecia';
  69.  


Niby wszystko ok (bynajmniej jesli chodzi o pomniejszanie) jednak obraz i miniatura zapisuja sie w katalogu glownym htdocs a nie w docelowych: $imagepath i $s_path.
Co jest nie tak?
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 19.08.2025 - 18:48