Matthew
Matthew

Reputation: 91

PHP File Transfer Script .. ALMOST DONE!

Can someone figure out what this is not working? I kept trying different things, double checking syntax etc but I get the error message I have setup for when a file does not transfer. This is my first PHP script.

I appreciate any help I will do research in the meantime.

Using NetBeans

<?php
$user = "username";
$password = "password";
$server_file = 'mag_hounddog.mp3';
$local_file = 'C:\users\kazuiman\desktop\mag_hounddog.mp3';

$ftp_server = "ftp.mysite.com";

// setup a basic connection to the ftp server
$connectionID = ftp_connect($ftp_server) or die("Connection was Not Successful");

// login with username and password for your account
$loginResult = ftp_login($connectionID, $user, $password);

echo ftp_pwd($connectionID);

// changes the directory to the tvstation you can hard code one in here.

if (ftp_chdir($connectionID, "test1nbiiwcdp_apps/tv2beta/streams/_definst_/")) {
    echo "Current Directory is Now..." . ftp_pwd($connectionID) . "\n";
} else {
    echo "Error Changing Directory .. perhaps it doesn't exist?";
}

// Now to download the files and put them onto your local machine
if (ftp_get($connectionID, $local_file, $remote_file, FTP_BINARY)) {
    echo "Succesfully written $server_file to $local_file\n";
} else {
    echo "There was a problem with the FTP transfer please check script\n";
}

// close the connection
ftp_close($connectionID)

?>

Upvotes: 0

Views: 892

Answers (1)

Mads Ohm Larsen
Mads Ohm Larsen

Reputation: 3715

You have never defined the variable $remote_file.

In your preamble it is called $server_file.

Is this a copy-paste-error?

Upvotes: 1

Related Questions