Hi,
I want to upload a local file to a ftp server. It gives an error, because he only can copy from the directory on the server where the site is running. I know this question is asked earlier, but there wasn't an answer given. I get this error: Warning: error opening test.txt in /serverdir/uploadfile.php on line 23.
This is my script:
<?php
include("ftp.php");
// set up basic connection
$conn_id = 0;
$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!<br>";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
} else {
echo "Connected to $ftp_server, for user $ftp_user_name <br>";
}
// upload the file
$destination_file.=$HTTP_POST_VARS["uit"];
$source_file=$HTTP_POST_FILES["bestand"]["name"];
$grootte=$HTTP_POST_FILES["bestand"]["size"];
$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 <br>";
echo "Size: $grootte";
}
// close the FTP stream
ftp_quit($conn_id);
?>
Thanks in advance!