Jump to content

FTP Get


Asheeown

Recommended Posts

Nothing in php.ini that says I can't download anywhere this big of a file so thats not the problem, I reversed the script and told it to put this time and still it outputted false, I'm starting to think that it might be logged in as a guest or something and just can't download or do anything, is their a way to check the status of the connection?

Link to comment
Share on other sites

<?php
include("include/Config.php");
// Set Variables
$Server = "***.***.***.***";					// Remote Server
$Username = "********";							// Remote Server Username
$Password = "*********";					// Remote Server Password
$Directory = "***";							// Remote Server Directory
$Type = "Raw"; 								// Example: Raw
$Table = "sansay_raw";						// CDR Table name
$LocalDirectory = "CDRS/";				// CDR Local Directory

// Do not change anything below this line
$LocalDirectory = $LocalDirectory . $Type;
$FtpConnect = ftp_connect($Server);
$Login = ftp_login($FtpConnect, $Username, $Password);

ftp_chdir($FtpConnect, $Directory);
echo "Current Directory: ";
echo ftp_pwd($FtpConnect);
echo "<br /><br /><br />";
$Files = ftp_nlist($FtpConnect, ".") or die("Line 21");


foreach($Files as $f) {
$Remote = "/$Directory/$f";
$Local = "$f";
$LocalF = fopen($Local,'w');
echo "File: $Remote is being written as $Local<br>";
if(ftp_fget($FtpConnect, $LocalF, $Remote, FTP_BINARY)) {
	echo "File: $Remote was downloaded successfully";
} else {
	echo "File: $Remote was not downloaded";
}
fclose($LocalF);

}
ftp_close($FtpConnect);
?>

 

Absolutely everything on the page, all personal information *ed

Link to comment
Share on other sites

I edited the code slightly to only try and download the files we want but it works perfectly for me remotely to my FTP:

foreach($Files as $f) {
        $Remote = "/$Directory/$f";
        $Local = "$f";
        if( preg_match( '/\.(cdr|php|txt|jpg|jpeg|gif)$/i', $Local ) )
        {
                $LocalF = fopen($Local,'w');
                echo "File: $Remote is being written as $Local<br>";
                if(ftp_fget($FtpConnect, $LocalF, $Remote, FTP_BINARY)) {
                        echo "File: $Remote was downloaded successfully";
                } else {
                        echo "File: $Remote was not downloaded";
                }
                fclose($LocalF);
        }

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.