|
-
Jan 9th, 2007, 11:25 PM
#1
Thread Starter
Member
Warning: ftp_fget()
I made a script to download huge content (.zip) from ftp site. i can see dowloading the content but at the end of downloading. content seems o kb with following errors:
Warning: ftp_fget() [function.ftp-fget]: Opening BINARY mode data connection for 200701.zip (516269909 bytes). in D:\ VSN_TMS\ftp_downloader.php on line 50
Could anybody help me out.
with Regards
Ramesh
-
Jan 10th, 2007, 01:37 AM
#2
-
Jan 10th, 2007, 01:45 AM
#3
Thread Starter
Member
Re: Warning: ftp_fget()
Here's the code
###################################################
<?php
//////////////////////////////////////////////////////Following Script Dowloads contents from Phonocat FTP Server Respective folders///////////////////////
set_time_limit(0);
// Videoservicesftp server connection variables
$ftp_server = "@@@@@@";
$conn_id = ftp_connect($ftp_server) or die("Unable to connect to the server");
$ftp_user_name = "@@@@";
$ftp_user_pass = "@@@@@";
//////////////////////////////////////////////////////////LOGIN WITH USER AND PASSWORD//////////////////////////////////////////////
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
////////////////////////////////CHECHK FTP CONNECTION ////////////////////////////////////////////////////////////////////////
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
/////////////////////////// GET FTP DIRECTORY /////////////////////////////////////////////////////////////////////////////
if (ftp_chdir($conn_id, "pub2")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
} else {
echo "Couldn't change directory\n";
}
echo "<br>";
$curdir = ftp_pwd($conn_id);
////////////////////////////////////////////DOWNLOADING FILES//////////////////////////////////////////////////////////////////////
$buff = ftp_nlist($conn_id, $curdir);
for ($i=0;$i<count($buff);$i++){
downLoadFile($buff[$i]);
}
/////////fUNCTION TO DOWNLOAD FILES //////////////////
function downLoadFile($filename){
global $conn_id;
$path=pathinfo($filename);
$path1="ftp_downloaded/".$path['basename'];
if(($path['basename']==".") || ($path['basename']==".."))
return;
print $path1."<BR>";
$fh=fopen($path1,"w+");
echo $downloadfile = ftp_fget($conn_id,$fh,$filename, FTP_BINARY,0);
fclose($fh);
if (!$downloadfile) {
echo "Ftp download has failed!<BR>Retrying the downloading process<BR>";
downLoadFile($filename);
}
else {
echo "Downloaded Success<BR>";
}
}
//close the connection
ftp_close($conn_id);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
####################################################
-
Jan 10th, 2007, 07:38 AM
#4
Re: Warning: ftp_fget()
 Originally Posted by RameshChaudhary
I made a script to download huge content (.zip) from ftp site. i can see dowloading the content but at the end of downloading. content seems o kb with following errors:
Warning: ftp_fget() [function.ftp-fget]: Opening BINARY mode data connection for 200701.zip (516269909 bytes). in D:\ VSN_TMS\ftp_downloader.php on line 50
Could anybody help me out.
with Regards
Ramesh
Use ftp_pasv() to turn passive more on before making the call to ftp_get():
PHP Code:
ftp_pasv($conn_id, true);
-
Jan 11th, 2007, 01:01 AM
#5
Thread Starter
Member
Re: Warning: ftp_fget()
 Originally Posted by visualAd
Use ftp_pasv() to turn passive more on before making the call to ftp_get():
PHP Code:
ftp_pasv($conn_id, true);
This does not worked. The problem remains same..
ramesh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|