Ich möchte einzelnen Personen ermöglichen, Dateien auf eine Domain zu laden ohne ein FTP-Programm zu benützen.
Allerdings beiße ich mir mit ftp_put() und den Pfadangaben auf Win9-Systemen die Zähne aus.
"C:\test.txt", "file:///c|test.txt" etc. , nichts funkzt :-(
Anbei das Script.
Für die Hilfe im Voraus vielen Dank!
Gregor
<?php
$destination_file = "neu/test.txt";
$source_file = "C:\test.txt";
$ftp_server = "servername";
$ftp_user_name = "user";
$ftp_user_pass = "passwort";
// set up basic connection
$conn_id = ftp_connect("$ftp_server");
// login with username and password
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "Ftp connection has failed!";
echo "Attempted to connect to $ftp_server for user $user";
die;
} else {
echo "Connected to $ftp_server, for user $user";
}
// upload the file
$mkdir_neu = ftp_mkdir($conn_id,"neuVerz");
$upload = ftp_put($conn_id, "$destination_file", "$source_file", FTP_BINARY);
// check upload status
if (!$upload) {
echo "Ftp upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_quit($conn_id);
?>
Allerdings beiße ich mir mit ftp_put() und den Pfadangaben auf Win9-Systemen die Zähne aus.
"C:\test.txt", "file:///c|test.txt" etc. , nichts funkzt :-(
Anbei das Script.
Für die Hilfe im Voraus vielen Dank!
Gregor
<?php
$destination_file = "neu/test.txt";
$source_file = "C:\test.txt";
$ftp_server = "servername";
$ftp_user_name = "user";
$ftp_user_pass = "passwort";
// set up basic connection
$conn_id = ftp_connect("$ftp_server");
// login with username and password
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "Ftp connection has failed!";
echo "Attempted to connect to $ftp_server for user $user";
die;
} else {
echo "Connected to $ftp_server, for user $user";
}
// upload the file
$mkdir_neu = ftp_mkdir($conn_id,"neuVerz");
$upload = ftp_put($conn_id, "$destination_file", "$source_file", FTP_BINARY);
// check upload status
if (!$upload) {
echo "Ftp upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_quit($conn_id);
?>