Ciao a tutti....
Ho qualche problemino a far funzionare un semplicissimo script:
Codice PHP:
<?php
$ftp=ftp_connect ("ftp.marsicano.org") or die ("NO connessione con host");
ftp_login ($ftp,"ciao@marsicano.org","ciao") or die ("NO login");
$file="file.txt";
$fs = filesize($file);
define('FTP_CHUNK_SIZE', intval($fs * 0.1) ); // upload ~10% per iteration
$localfile = fopen($file,'rb');
$i = 0;
while( $i < $fs ) {
$tmpfile = fopen('tmp_ftp_upload.bin','ab');
fwrite($tmpfile, fread($localfile, FTP_CHUNK_SIZE));
fclose($tmpfile);
ftp_put($ftp, 'remote_file.bin', 'tmp_ftp_upload.bin', FTP_BINARY, $i);
// Remember to put $i as last argument above
$progress = (100 * round( ($i += FTP_CHUNK_SIZE) / $fs, 2 ));
file_put_contents('ftp_progress.txt', "Progress: {$progress}%");
}
fclose($localfile);
unlink('ftp_progress.txt');
unlink('tmp_ftp_upload.bin'); // delete when done
//And file to check with ajax:
if (file_exists('ftp_progress.txt'))
echo file_get_contents('ftp_progress.txt');
else
echo 'Progress: 0%';
exit;
?>
L'idea è quella di creare un qualcosa che, dato un file in ingresso, lo carichi tramite FTP e mostri anche lo stato corrente.
Il problema è che scrivere sempre e solo:
Consigli?? Aiuti???
Grazie 1000