Reputation: 19895
I would like to create a file on a FTP server from a variable's content. Is this possible without writing the data to a file locally first ?
This is what I can do:
$tmpfname = tempnam("/tmp", "FOO");
file_put_contents($tmpfname, $file_contents)
ftp_put($conn_id, $destination_file, $tmpfname, FTP_BINARY);
unlink($tmpfname);
But I would like to send $file_contents
without saving it first to a file.
Upvotes: 0
Views: 376
Reputation: 7433
It's possible using wrappers:
ftp_put($conn_id, $destination_file, 'data://text/plain;base64,' . base64_encode($file_contents), FTP_BINARY);
Upvotes: 1