Wiecie może czemu ten kod za pierwszym przebiegiem (czyli kiedy pliku nie ma na lokalnym serwerze) robi wszystkie operacje prawidłowo, ale nie wyświetla samej miniaturki?

  1. <?php
  2. $url = 'http://i-serwis2.action.pl/';
  3. $filename = 'Pictures/KOM/KOH/KOMAAAKOH0397/1.jpg';
  4. $width = 480;
  5. $height  = 480;
  6.  
  7. header('Content-type: image/jpeg');
  8.  
  9. if (file_exists($filename))
  10. {
  11. $source = imagecreatefromjpeg($filename);
  12. imagejpeg($source, null, 10);
  13. } else {
  14. $dir = '/';
  15. foreach (array_slice(explode('/', $filename), 0, -1) as $value)
  16. {
  17. mkdir($dir.$value);
  18. $dir .= $value . '/';
  19. }
  20.  
  21. list($fwidth, $fheight) = getimagesize($url.$filename);
  22. if ($width/$height > $fwidth/$fheight)
  23. {
  24. $newwidth = ceil($fwidth/($fheight/$height));
  25. $newheight = $height;
  26. } else {
  27. $newwidth = $width;
  28. $newheight = ceil($fheight/($fwidth/$width));
  29. }
  30. $thumb = imagecreatetruecolor($newwidth, $newheight);
  31. $source = imagecreatefromjpeg($url.$filename);
  32. imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $fwidth, $fheight);
  33. imagejpeg($thumb, $filename, 100);
  34. }
  35. ?>


Miniaturka ładowana z dysku lokalnego ma celowo ustawioną jakość na 10% żeby było wiadomo czy jest to miniaturka lokalna czy zdalna. winksmiley.jpg

//EDIT

Dałem po prostu na końcu
  1. <?php
  2. ...
  3. header('location:' . $_SERVER['PHP_SELF']);
  4. }
  5. ?>
. smile.gif