Help with image resizing

Discussion in 'PHP' started by herando, May 25, 2006.

  1. #1
    hi all,

    i choose a image file from form field and upload. but the browser shows such errors:
    Notice: Undefined variable: uploadfile in c:\program files\apache group\apache\htdocs\u-r\upload.php on line 20

    Notice: Undefined variable: uploadfile in c:\program files\apache group\apache\htdocs\u-r\upload.php on line 23

    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in c:\program files\apache group\apache\htdocs\u-r\upload.php on line 37

    Notice: Undefined index: uploadfile in c:\program files\apache group\apache\htdocs\u-r\upload.php on line 42

    Warning: imagedestroy(): supplied argument is not a valid Image resource in c:\program files\apache group\apache\htdocs\u-r\upload.php on line 45

    could anyone help me, please. here is the resizing code:

    <?php
    $uploadedfile = $_FILES['uploadfile']['tmp_name'];
    $src = imagecreatefromjpeg($uploadfile);
    list($width,$height)=getimagesize($uploadfile);

    $newwidth=260;
    $newheight=195;
    $tmp=imagecreatetruecolor($newwidth,$newheight);

    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

    $filename = "../images". $_FILES['uploadfile']['name'];

    imagedestroy($src);
    imagedestroy($tmp);
    ?>
     
    herando, May 25, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you got the right libraries installed on your server?
     
    mad4, May 25, 2006 IP
  3. herando

    herando Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes. gd enabled.
     
    herando, May 25, 2006 IP
  4. Bartbos

    Bartbos Peon

    Messages:
    29
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just read! You've named the variable $uploadEDfile and later on you use $uploadfile.

    :)
     
    Bartbos, May 27, 2006 IP