Speed up development with full-stack environments for every branch.

Learn More

How to create a basic ftp connection with ftp_connect()

103 Runs 708 Views 162 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php

/**
 * PHP ftp module
 * Basic ftp connection with ftp_connect()
 */

// set up the url for the connection
$ftp_server = "ftp.bls.gov";
//connect to the server
$conn_id = ftp_connect($ftp_server);

//test if the connection is successful
echo '<center>';
$conn_id = ftp_connect($ftp_server);
if (!$conn_id)
    echo '<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">
    Couldn\'t connect to <b>' . $ftp_server . '</b></div>';
else
    echo '<div style="background-color:green;padding:10px;color:#fff;font-size:16px;">
    Connected to <b>' . $ftp_server . '</b></div>';
echo '</center>';


// close the FTP stream 
ftp_close($conn_id);
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).