PHP FTP upload script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hoelli86
Forum Newbie
Posts: 1
Joined: Tue Feb 03, 2004 2:20 pm
Contact:

PHP FTP upload script

Post by hoelli86 »

Hello

I want to do with my script this things:

I want to upload files from my computer to the ftp server. But I don't know how i can choose the files. How i should define the variable destination_file, source_file

Thanks for Help!
:o
<?php
// Herstellen der Basis-Verbindung


$ftp_server="ftp.blabla.com";
$ftp_user_name="username";
$ftp_user_pass="password";

$conn_id = ftp_connect("$ftp_server");

// Einloggen mit Benutzername und Kennwort
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");

// Verbindung überprüfen
if ((!$conn_id) || (!$login_result)) {
echo "Ftp-Verbindung nicht hergestellt!";
echo "Verbindung mit $ftp_server als Benutzer $user nicht möglich";
die;
} else {
echo "Verbunden mit $ftp_server als Benutzer $user";
}

// Upload der Datei
$upload = ftp_put($conn_id, "$destination_file", "$source_file", FTP_BINARY);

// Upload-Status überprüfen
if (!$upload) {
echo "Ftp upload war fehlerhaft!";
} else {
echo "Datei $source_file auf $ftp_server als $destination_file geschrieben";
}

// Schließen des FTP-Streams
ftp_quit($conn_id);
?>
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

any chance of the comments in english?

and cant you just use an ftp program?
Post Reply