Salve ragazzi...sto lavorando alla tesi universitaria, devo realizzare un modulo per il caricamento file via ftp, ma la funziona ftp_put() mi da sempre questo errore:

Warning: ftp_put() [function.ftp-put]: Can't open that file: No such file or directory in /web/htdocs/home/uploadftp.php on line 124
2. FTP upload has encountered an error!

La connessione avviene, le due cartelle me le crea correttamente, con i permessi 777!

Per farlo il codice realizzato è il seguente:
Codice PHP:
         //Ricavo dell'id dell'user della sessione corrente!
         
$utente= @mysql_query("SELECT id FROM utenti WHERE  user_id=\"$_SESSION[user111]\"  ");
         
$utente1 mysql_fetch_array($utente);    
    
        
$id=mysql_query("SELECT max(id) FROM progetto") or die (mysql_error());
        
$id_max=mysql_fetch_array($id);
        
$prog=$id_max[0]+1;
        
//Creo cartella con l'id della tesina!
        
$dir='tesine/'.$utente1[0].'/'.$prog.'/';
        
        
$old_umask umask(0);        
        
$crea = @mkdir($dir0777);
        
umask($old_umask);    

        
$filep=$_FILES['file_readme']['tmp_name'];
        
$name=$_FILES['file_readme']['name'];

set_time_limit(300);//for uploading big files
    
$paths=$dir;

$ftp_server='xxxx';

$ftp_user_name='xxx';

$ftp_user_pass='xxx';

// set up a connection to ftp server
$conn_id ftp_connect($ftp_server);

// login with username and password
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// check connection and login result
if ((!$conn_id) || (!$login_result)) {
       echo 
"1. FTP connection has encountered an error!";
       echo 
"Attempted to connect to $ftp_server for user $ftp_user_name....";
       exit;
   } else {
       echo 
"Connected to $ftp_server, for user $ftp_user_name".".....";
   }

// upload the file to the path specified
echo $dir.$name."
"
;

$upload ftp_put($conn_id$dir.$name$filepFTP_ASCII);

// check the upload status
if (!$upload) {
       echo 
"2. FTP upload has encountered an error!";
   } else {
       echo 
"Uploaded file with name $name to $ftp_server ";
   }

// close the FTP connection
ftp_close($conn_id);