PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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
Last edited by Burrito on Mon Mar 07, 2005 5:01 pm, edited 2 times in total.
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.
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
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:
$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....