PHP FTP Download; How to indicate download progress!

Hello,

I am trying to write a program that downloads files from an ftp server. The files download fine, but there is no progress indicator. I desperately need to display some kind of progress about the download but the ftp_get() just displays a blank page while the file is being downloaded. Any kind of help will be appreciated!

Thanks!
Asad

I think Harry’s blog mentioned a PEAR progress bar package a while back, might be worth searching there.

Yep, think it was a PEAR package if I remember though ? But me memory if pretty bad nowadays :wink:

This example link was given:
http://www.joelpittet.com/test/example.php

Thanks guys, i will definately look into that. But i am facing a much more basic problem. As i said i was having no problems using ftp_get(), but i was working from my home computer. At my office i tried doing the same thing and now it gives me the following error.

Warning: ftp_get() [function.ftp-get]: Error opening c:/thefile.txt in D:\allaccess\Inetpub\wwwroot\dd\ est2.php on line 11
ERROR: Couldn’t get filePHP Warning: ftp_get() [function.ftp-get]: Error opening c:/thefile.txt in D:\allaccess\Inetpub\wwwroot\dd\ est2.php on line 11

That is wierd because the ‘thefile.txt’ is the name of the “local file”. I mean it is to be stored on my computer, i don’t know why its giving that error. My code is as follow:(got it from some website)

<?php
$ftp_server = “www.myhost.com”;

$conn = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn, “myuser”, “mypass”);

if(ftp_chdir($conn, “wwwroot”)){
$gotFile = ftp_get($conn, “c:/thefile.txt”, “readme.txt”, FTP_ASCII);

if($gotFile){
	$fp = fopen("c:/thefile.txt", "rb");

while($data = fgets($fp, 1024)){
	echo $data;
}

@fclose($fp);
}
else{
	echo "ERROR: Couldn't get file";
}

}

else{
echo “ERROR: Couldn’t change directories”;
}

?>

Does it have anything to do with permissions, if so then how come permissions matter on your local machine ?? Thanks!!

Asad

Asad, hope you will login to this page… Anyway… I have the same problem as what you are facing… Just wondering if you have any solution. Would you please be kindly enough to let me know…
Thanks,…

I have the same problem as that of yours.
Just wondering if you have any solution. Would you please be kind enough to let me know…
Thanks…