Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> upload zdjecia + zmiana rozmiaru
bumfank
post
Post #1





Grupa: Zarejestrowani
Postów: 87
Pomógł: 0
Dołączył: 29.02.2004
Skąd: /dev/null

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


Witam mam 2 skrypty:
  1. <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"30000000\">
  2. Plik do wysłania: <input name=\"src\" type=\"file\">
  3. <input type=\"submit\" value=\"wyslij\" name=\"zdjecie\">
  4. </form>
  5.  
  6. <?php
  7. if ($zdjecie=='wyslij')
  8.  {
  9.  
  10.  
  11.  
  12. if( is_uploaded_file( $_FILES['src']['tmp_name'] ) )
  13. {
  14.  
  15. $strUploadDir = 'images/' . $_FILES['src']['name'];
  16. if( move_uploaded_file( $_FILES['src']['tmp_name'], $strUploadDir ) )
  17. {
  18. echo 'Plik został pomyślnie uploadowany! <br />';
  19. }
  20. else
  21. {
  22. echo 'Upload pliku nie powiódł się!';
  23. }
  24. echo 'Dodatkowe informacje o uploadowanym pliku: <pre>' . print_r( $_FILES, true ) . '</pre>';
  25. }
  26. else
  27. {
  28. echo 'Wystąpił błąd podczas wysyłania pliku na serwer!';
  29. }
  30. }
  31. ?>

do uploadniecia zdjecia
oraz do zmiany rozmiaru:
  1. <?php
  2. function resizePicture ($src, $dest, $maxWidth = 300, $maxHeight = 300, $quality = 70) {
  3.  
  4. if (file_exists($src) && isset($dest)) { 
  5. // path info 
  6. $destInfo = pathInfo($dest); 
  7.  
  8. // image src size 
  9. $srcSize = getImageSize($src); 
  10.  
  11. // image dest size $destSize[0] = width, $destSize[1] = height 
  12. $srcRatio = $srcSize[0]/$srcSize[1]; // width/height ratio 
  13. $destRatio = $maxWidth/$maxHeight; 
  14. if ($destRatio > $srcRatio) { 
  15. $destSize[1] = $maxHeight; 
  16. $destSize[0] = $maxHeight*$srcRatio; 
  17. } 
  18. else { 
  19. $destSize[0] = $maxWidth; 
  20. $destSize[1] = $maxWidth/$srcRatio; 
  21. } 
  22.  
  23. // path rectification 
  24. if ($destInfo['extension'] == &#092;"gif\") { 
  25. $dest = substr_replace($dest, 'jpg', -3); 
  26. } 
  27.  
  28. // true color image, with anti-aliasing 
  29. $destImage = imageCreateTrueColor($destSize[0],$destSize[1]); 
  30. imageAntiAlias($destImage,true); 
  31.  
  32. // src image 
  33. switch ($srcSize[2]) { 
  34. case 1: //GIF 
  35. $srcImage = imageCreateFromGif($src); 
  36. break; 
  37.  
  38. case 2: //JPEG 
  39. $srcImage = imageCreateFromJpeg($src); 
  40. break; 
  41.  
  42. case 3: //PNG 
  43. $srcImage = imageCreateFromPng($src); 
  44. break; 
  45.  
  46. default: 
  47. return false; 
  48. break; 
  49. } 
  50.  
  51. // resampling 
  52. imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]); 
  53.  
  54. // generating image 
  55. switch ($srcSize[2]) { 
  56. case 1: 
  57. case 2: 
  58. imageJpeg($destImage,$dest,$quality); 
  59. break; 
  60.  
  61. case 3: 
  62. imagePng($destImage,$dest); 
  63. break; 
  64. } 
  65. return true; 
  66. } 
  67. else { 
  68. return false; 
  69. } 
  70. }
  71.  
  72. ?>


teraz sie zastanawiam jak to podlaczyc
ja to wykombinowalem ze w linijce:
  1. <?php
  2. if( is_uploaded_file( $_FILES['src']['tmp_name'] ) )
  3. { DODALEM TUTAJ SKRYPT ZMIANA ROZMIARU $strUploadDir = 'images/' . $_FILES['src']['name'];
  4. if( move_uploaded_file( $_FILES['src']['tmp_name'], $strUploadDir ) )
  5. {..................
  6. ?>

i wysyla ale nie zmienia tego cholernego rozmiaru sad.gif moze jakies inne pomysly questionmark.gif
prosze o pomoc exclamation.gif


--------------------
Drukuj24.pl - Drukowanie to koszt
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: 21.08.2025 - 17:44