Mam skrypt, wrzucam, zmniejsza mi ale nie dostosowuje szerokości mam tylko mały prostokąt, co jest nie tak?ustawiłem na sztywno maxy i dalej nic.

  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4. $allowed = array ('image/pjpeg', 'image/JPEG', 'image/JPG', 'image/jpeg', 'image/jpg', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png', 'image/gif');
  5. if(in_array($_FILES['userfile']['type'],$allowed))
  6. {
  7. $url='../rsah/upload/';
  8. $turl='../rsah/thumb/';
  9. $tmpName=$_FILES['userfile']['tmp_name'];
  10. $name=$_FILES['userfile']['name'];
  11. //do miniaturek
  12. static $maxWidth=150;
  13. static $maxHeight=150;
  14.  
  15. list($sHeight,$sWidth,$sType)=getimagesize($tmpName);
  16.  
  17. switch($sType)
  18. {
  19. case IMAGETYPE_GIF:
  20. $gType=imagecreatefromgif($tmpName);
  21. break;
  22. case IMAGETYPE_PNG:
  23. $gType=imagecreatefrompng($tmpName);
  24. break;
  25. case IMAGETYPE_JPEG:
  26. $gType=imagecreatefromjpeg($tmpName);
  27. break;
  28. default:
  29. echo 'co tam?';
  30. }
  31.  
  32. $sourceRatio=$sWidth/$sHeight;
  33. $thumbnailRatio=$maxWidth/$maxHeight;
  34.  
  35. if($sWidth<=$maxWidth && $sHeight<=$maxHeight)
  36. {
  37. $tWidth=$sWidth;
  38. $tHeight=$sHeight;
  39. }
  40. else if ($thumbnailRatio>$sourceRatio)
  41. {
  42. $tWidth= (int) ($maxHeight * $sourceRatio);
  43. $tHeight= $maxHeight;
  44. }
  45. else
  46. {
  47. $tWidth= $maxWidth;
  48. $tHeight= (int) ($maxWidth/$sourceRatio);
  49. }
  50.  
  51. $thumbnailImage=imagecreatetruecolor($tWidth,$tHeight);
  52. imagecopyresampled($thumbnailImage,$gType,0,0,0,0,$maxWidth,$maxHeight,$sWidth,$sHeight);
  53. imagejpeg($thumbnailImage,$turl.$name,90);
  54. imagedestroy($gType);
  55. imagedestroy($thumbnailImage);
  56.  
  57. move_uploaded_file($tmpName,$url.$name);
  58.  
  59. echo 'Wrzucono';
  60. }
  61. else
  62. {
  63. echo $_FILES['userfile']['tmp_name'];
  64. echo '</br>';
  65. echo $_FILES['userfile']['name'];
  66. echo '</br>';
  67. echo $_FILES['userfile']['type'];
  68. echo '</br>';
  69. echo 'Bledny typ';
  70. }
  71. }
  72. else
  73. {
  74. echo 'wrzuc cos';
  75. }
  76. ?>