Can anyone help me with this. I have made a form that uploads a image, renames it, creates another copy, chmods them both to 777(so they can be resized,
Then they should be resized thanks to the function chmod'd back to normal then displayed.

It works up untill they get resized? Any one with any ideas?

//the function called later on. 
function resizeImage($filename,$path,$limitWidth) { 

list($initWidth, $initHeight) = getimagesize($UploadFileName); 

if($initWidth > $limitWidth) { 
    $per = sprintf('%01.4f',$limitWidth / $initWidth); 
    $newwidth = sprintf('%01.0f',$per * $initWidth); 
    $newheight = sprintf('%01.0f',$per * $initHeight); 

    set_time_limit(3000); 
    ini_set("memory_limit","30M"); 

    $image_type = strstr($filename, '.'); 
    switch(strtolower(strtoupper($image_type))) { 
        case '.jpg': 
            $source = imagecreatefromjpeg($path.$filename); 
            break; 
        case '.png': 
            $source = imagecreatefrompng($path.$filename); 
            break; 
        case '.gif': 
            $source = imagecreatefromgif($path.$filename); 
            break; 
        default: 
            echo("Error Invalid Image Type"); 
            die; 
            break; 
    } 

    $fullpath = $path . $filename; 
    list($width, $height) = getimagesize($path.$filename); 
    $thumb = imagecreatetruecolor($newwidth, $newheight); 
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight); 
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
    imagejpeg($thumb, $fullpath, 100); 
    $filepath = $fullpath; 
} 

return $filepath; 
} 

/end function                   
//UPLOADS FILE TO SERVER $UploadDir = 'images/'; $path = $UploadDir; $UploadFileName = $UploadDir . time()."--". $_FILES['userfile']['name']; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $UploadFileName)) { //set names $file1 = $UploadFileName; $file2 = "images/number2".time()."--". $_FILES['userfile']['name']; //chmod orignal, then copy it, then chmod copy. chmod($file1, 0777); copy($file1, $file2); chmod($file2, 0777); //sets name to resize $file1_resize = time()."--". $_FILES['userfile']['name']; $file2_resize = "number2".time()."--". $_FILES['userfile']['name']; /*I get to here and these two are not working, the images are not resizing */ $thumb = resizeImage($file1_resize,$UploadDir,149); $full = resizeImage($fiel2_resize,$UploadDir,402); echo("<img src=\"$thumb\">"); echo("<img src=\"$full\">"); }

Thanks

    Write a Reply...