Upload Script Ordner Angabe

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Upload Script Ordner Angabe

    Hallo zusammen,

    bin neu hier und wollte zunächst einmal hallo sagen!

    Ich habe folgendes Script, womit ich Bilder Uploaden kann und gleichzeitig verkleinern kann:

    Quellcode

    1. <?php
    2. // Filename to store image as
    3. $FILENAME=$user_info['user_name'];
    4. // Width to reszie image to
    5. $RESIZEWIDTH=100;
    6. // Width to reszie image to
    7. $RESIZEHEIGHT=75;
    8. function ResizeImage($im,$maxwidth,$maxheight,$name){
    9. $width = imagesx($im);
    10. $height = imagesy($im);
    11. if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
    12. if($maxwidth && $width > $maxwidth){
    13. $widthratio = $maxwidth/$width;
    14. $RESIZEWIDTH=true;
    15. }
    16. if($maxheight && $height > $maxheight){
    17. $heightratio = $maxheight/$height;
    18. $RESIZEHEIGHT=true;
    19. }
    20. if($RESIZEWIDTH && $RESIZEHEIGHT){
    21. if($widthratio < $heightratio){
    22. $ratio = $widthratio;
    23. }else{
    24. $ratio = $heightratio;
    25. }
    26. }elseif($RESIZEWIDTH){
    27. $ratio = $widthratio;
    28. }elseif($RESIZEHEIGHT){
    29. $ratio = $heightratio;
    30. }
    31. $newwidth = $width * $ratio;
    32. $newheight = $height * $ratio;
    33. if(function_exists("imagecopyresampled")){
    34. $newim = imagecreatetruecolor($newwidth, $newheight);
    35. imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    36. }else{
    37. $newim = imagecreate($newwidth, $newheight);
    38. imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    39. }
    40. ImageJpeg ($newim,$name . ".jpg");
    41. ImageDestroy ($newim);
    42. }else{
    43. ImageJpeg ($im,$name . ".jpg");
    44. }
    45. }
    46. if($_FILES['image']['size']){
    47. if($_FILES['image']['type'] == "image/pjpeg" || $_FILES['image']['type'] == "image/jpeg"){
    48. $im = imagecreatefromjpeg($_FILES['image']['tmp_name']);
    49. }elseif($_FILES['image']['type'] == "image/x-png" || $_FILES['image']['type'] == "image/png"){
    50. $im = imagecreatefrompng($_FILES['image']['tmp_name']);
    51. }elseif($_FILES['image']['type'] == "image/gif"){
    52. $im = imagecreatefromgif($_FILES['image']['tmp_name']);
    53. }
    54. if($im){
    55. if(file_exists("$FILENAME.jpg")){
    56. unlink("$FILENAME.jpg");
    57. }
    58. ResizeImage($im,$RESIZEWIDTH,$RESIZEHEIGHT,$FILENAME);
    59. ImageDestroy ($im);
    60. }
    61. }
    62. ?>
    Alles anzeigen


    Wie mache ich das, dass die geuploadeten Bilder in dem Ordner data/avatars gespeichert werden?