I'm having a problem connecting 2 different processes that I have working. I've been tasked with pulling data out of a database, creating a file from the data, and then uploading it to an ftp server.
So far, I have the file being created and downloadable using this code, $out being a string that contains the complete text file:
if ($output == 'file')
{
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: ".strlen($out));
header("Content-type: application/txt");
header("Content-Disposition: attachment; filename=".$file_name);
echo($out);
}
This works when I want to just run the script in a browser and download the file, but I'm looking to instead send it to an ftp server.
I know my connection to the ftp server is working just fine, and I'm correctly navigating to the correct directory, and I've taken files from disk and put them on the ftp using ftp_put(), but I'm looking to take $out and write it directly as a file with $filename as its name on the FTP server. I may be misreading things, but when I tried ftp_put and ftp_fput, it seemed that they want file locations, not file streams. Is there a different function I could consider?