I want to post FTP hyperlinks to save files from a remote server to a local machine. I tried the following code among other solutions with no luck. Will someone please help or make recommendations? I would like an alert box to pop up providing the ability to save the file in a desired local directory.
function downLoad ()
{
$local_file = 'C:\testFTP\';
$server_file = 'path/imagejpg;
$conn_id = ftp_connect("ftp Server");
// login with username and password
$login_result = ftp_login($conn_id, "ftp user", "ftp password");
$handle = fopen("file to open", 'w');
// check connection
/*if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $conn_id for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
if (ftp_get($conn_id, $handle, "file to open (e.g. pdf file, image, etc.)", FTP_BINARY, 0)) {
echo "successfully written to $local_file\n";
}
// close the FTP stream
ftp_close($conn_id);
}