Page 1 of 1

[Solved] Status message before entire page load

Posted: Fri Mar 04, 2005 4:09 pm
by Burrito
I have a situation where users will be uploading files to our codification system here and some of them will then be uploaded to our streaming server (offiste) using ftp. Some of these files are friggin' ginormous so I would like to indicate to the users half way through that their file is still being worked on (as soon as the upload is complete to our server and prior to the upload to the offsite streaming server).

I tried the code below, but it doesn't display anythign until the whole process is done. I'm thinking I need some kind of ob_ something or other here, but not sure what exactly...please advise:
<?if(isset($message)){ echo "<div class=\"red\" align=\"center\">".$message."</div>"; } else {
if(
$initftp){
echo
"<span id=\"rmftp\">Your file has been uploaded to the LearningPathways server, now uploading to the PlayStream server....please wait</span>";
$conn_id = ftp_connect("ftp.ftpserver.com")
or die(
"could not connect to playstream.com");
$login_result = ftp_login($conn_id, "myUser", "myPass")
or die(
"could not log in to playstream.com");
$upload = ftp_put($conn_id, "lp/".$_FILES["bob"]["name"], "datafiles/".$dir.$_FILES["bob"]["name"], FTP_BINARY)
or die(
"could not upload to playstream.com");
ftp_close($conn_id);
echo
"<script>
document.getElementById('rmftp').innerHTML = \"Upload Complete<br>\";
</script>"
;
}
// end if for need to ftp rm files to playstream server...burrito
?>
thanks...

Burr

Posted: Fri Mar 04, 2005 4:12 pm
by feyd
flush()

Posted: Fri Mar 04, 2005 9:09 pm
by smpdawg
I have an animated progress bar hidden in a div until the submit is pressed. I make the div visible and process the form.

Posted: Fri Mar 04, 2005 11:24 pm
by Burrito
well the hidden div would work, but I want this two step process to show each stage of the process.

I got it working perfectly by having a hidden iframe on my submit page that I pass the vars to through the url. the iframe does the ftp upload while the parent page shows what is happening. As soon as the iframe is done processing the ftp upload, it changes a span using innerHTML to indicate the file is totally done....works like a champ.

Burr

Posted: Sat Mar 05, 2005 3:18 pm
by Todd_Z
I wonder if its possible to simply flush out a javascript line which would be a div.innerHTML change to show each step of the process? This way you could have the page show, then do the processing of the upload while showing the progress

Posted: Mon Mar 07, 2005 2:16 pm
by Burrito
ok, I thought I had this one solved...but I just ran into a stumbling block. I just tried it with a very large file and it doesn't change the span on my parent page to indicate the file is done...nor does it do the alert...see code below:
<?
require_once('includes/dbInteract.php');
    
tt_db_connect();

$conn_id = ftp_connect("ftp.playstream.com")
            or die(
"could not connect to playstream.com");
        
$login_result = ftp_login($conn_id, "username", "password")
            or die(
"could not log in to playstream.com");
        
$upload = ftp_put($conn_id, $_GET['t'], $_GET['s'], FTP_BINARY)
            or die(
"could not upload to playstream.com");
        
ftp_close($conn_id);
        if(
$upload){
        echo
"<script>
        alert('File Upload Process Complete');
        parent.document.getElementById('rmftp').innerHTML = \"Upload Complete<br>\";
        parent.clearInterval(parent.id);
        parent.document.getElementById('rmftp').style.color = '';
        parent.document.getElementById('done').style.display = 'block';
    </script>"
;
        }
// end if for show upload status...burrito
?>
it works fine with smaller files, but I'm thinking there is some kind of timeout setting I need to set for the echo statement to not die if the timeout time has been met....


EDIT: the file is being uploaded just fine, just the js isn't working right....

any suggestions?

thx,

Burr

Posted: Mon Mar 07, 2005 5:00 pm
by Burrito
set_time_limit(0) got me there...