ho creato un file .php che contiene:
Codice PHP:
<?php
$ftp=ftp_connect ("ftp.***.org") or die ("NO connessione con host");
ftp_login ($ftp,***@***.org","***") 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;
?>
<html>
<head>
<script type="text/javascript">
var XMLHttpRequestObject = false;
XMLHttpRequestObject = new XMLHttpRequest();
function loadHostFile (dataSource, divID) {
if (XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open("GET", dataSource, true);
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status==200) {
obj.innerHTML = '<textarea name="hostfilecontent" cols="75" rows="10" id="hostfilecontent">'+XMLHttpRequestObject.responseText+'</textarea>';
}
}
XMLHttpRequestObject.send();
}
}
</script>
</head>
<body onLoad="loadHostFile('ftp_progress.txt','hostfile')">
</body>
</html>
Ma non va

Parte il caricamento, ma io non vedo nulla...
Grazie 1000