I'm trying to upload a variable into a json file on my server todo so I use PHP to make connection and login to the FTP server. This is the code I use:
<?php
$ftp_server = $_POST["ftp_server"];
$database_url = $_POST["database_url"];
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $_POST["username"], $_POST["password"]);
$file = fopen('php://temp', 'r+');
fwrite($file, $_POST["pass_json"]);
if (ftp_nb_put($ftp_conn, $database_url, $file, FTP_ASCII)){
echo "Successfully uploaded $file.";
} else {
echo "Failed to upload $file.";
}
rewind($file);
ftp_close($ftp_conn);
?>
The connection is valid ($ftp_conn
). the login is valid as well ($login
).
$_POST["pass_json"]
is the correct information and $_POST["database_url"]
is the url you fill in your webbrowser to look at the json file in your webbrowser.
this is being done with a SSL certificate in https to protect the username and password given. What am I doing wrong?