Image upload error

Discussion in 'PHP' started by Lazaru5, Jun 14, 2007.

  1. #1
    I need help, (in more ways than one), but thats another story :D

    seriously tho, can someone please tell me what is wrong with this script

            if ($_POST['img_upload'] == 1)
    {
    	$mwidth = "100";
    	$mheight = "150";
    
            $uploadedfile = $_FILES['userpic']['tmp_name'];
    	$src = imagecreatefromjpeg($uploadedfile);
    
    	echo "file: ".$uploadedfile."<br>";
    	$size = getimagesize($uploadedfile);
    	for($i=0;$i<6;$i++)
    	{
       		echo "$i".$size[$i]."<br>";
    	}
    	$width = $size[0];
    	$height = $size[1];
    	echo "w".$width."<br>";
    	echo "h".$height."<br>";
    
            if ($height > $width)
    	{
    		$newheight = $mheight;
    		$newwidth = ($height/$width)*$mwidth;
    	}
    	else
    	{
    		$newwidth = $mwidth;
    		$newheight = ($width/$height)*$mheight;
    	}
    
    	$tmp = imagecreatetruecolor($newwidth,$newheight);
    	imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
    
    	$imgurl = md5($row_user['username']);
    	$filename = "images/userpictures".$imgurl;
    	imagejpeg($tmp,$filename,100);
    	imagedestroy($src);
    	imagedestroy($tmp);
    } 
    PHP:
    the error messages i get is
    the code begins at line 91 and ends at 129.

    I haven't written this code, i'm not a php programmer, but it was written FOR me, the guy that wrote it has gone awol :(

    please help.

    Laz
     
    Lazaru5, Jun 14, 2007 IP