Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

FTP To Get A File From Within PHP

DZone's Guide to

FTP To Get A File From Within PHP

·
Free Resource

$conn_id = ftp_connect("www.yoursite.com");
$login_result = ftp_login($conn_id, "username", "password");

if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected";
}

// get the file
$local = fopen("local.txt","w");
$result = ftp_fget($conn_id, $local,"httpdocs/trlog.txt", FTP_BINARY);

// check upload status
if (!$result) {
echo "FTP download has failed!";
} else {
echo "Downloaded ";
}

// close the FTP stream
ftp_close($conn_id);
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}