a me così funziona perfettamente:
pagina engine.php:
Codice PHP:
<?
$nome
=$_POST["nome"];
$file=$_FILES['file']['name'];
$tmp=$_FILES['file']['tmp_name'];
$cartellaDati="users/".$nome;
mkdir($cartellaDati,0755);
$path="users/".$nome."/";
$new_width=300;
$new_height=300;

$copy=$cartellaDati."/".$nome;
copy$tmp$copy )or die(mysql_error());
$nomeimage=$nome.".jpg";
resize($nomeimage$path$path$new_width$new_height);


//$new_width, $new_height sono le dimensioni della immagine finale

function resize($nomeimage$source_path$destination_path$new_width$new_height){
    list(
$width$height$type$attr) = getimagesize($source_path.$nomeimage);
    
$compression=100;
    
$destimg=imagecreatetruecolor($new_width,$new_height) or die("Problemi nelle creazioni dell'immagine");
    
$srcimg=ImageCreateFromJPEG($source_path.$nomeimage) or die("Problemi nell'aprire l'immagine");
    
$w=ImageSX($srcimg);
    
$h=ImageSY($srcimg);
    
$ro=$new_width/$new_height;
    
$ri=$w/$h;
    if(
$ro<$ri){
        
$par="h"//immagine alta, verticale
    
}else{
        
$par="w"//immagine larga, orizzontale
    
}
    if(
$par=="h"){
        
$ih=$h;
        
$conv=$new_width/$new_height;
        
$iw=$conv*$ih;
        
$cw=($w/2)-($iw/2);
        
$ch=($h/2)-($ih/2);
    }else if(
$par=="w"){
        
$iw=$w;
        
$conv=$new_height/$new_width;
        
$ih=$conv*$iw;
        
$cw=($w/2)-($iw/2);
        
$ch=($h/2)-($ih/2);
    }

//qui poi ci andrà messo un ciclo per verificare il tipo di immagine, ora diamo per scontato che sia jpg

    
ImageCopyResized($destimg,$srcimg,0,0,$cw,$ch,$new_width,$new_height,$iw,$ih) or die("Problemi nel ridimensionamento");
    
ImageJPEG($destimg,$destination_path.$nomeimage,$compression) or die("Problemi nel salvataggio");
}
?>
pagina index.php (il form):
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Documento senza titolo</title>
</
head>

<
body>
<
form action="engine.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  


    <
input name="nome" type="text" id="nome" />
</
p>
  


    <
input type="file" name="file" />
</
p>
  


    <
input type="submit" name="Submit" value="Invia" />
  </
p>
</
form>
</
body>
</
html