ConFoo Montreal 2026: Call for Papers

Voting

: max(five, eight)?
(Example: nine)

The Note You're Voting On

florian dot ember at gmail dot com
17 years ago
Currently, there is no function that lets you specifiy the file's contents as a string. However, there is ftp_fput(), which operates on an open file. Using this function in conjunction with tmpfile() lets you emulate this kind of function. (You could also use php://memory, but this breaks BC).

<?php
function ftp_fputs($ftp_stream, $remote_file, $contents, $mode, $startpos = 0)
{
$tmp = tmpfile();
fwrite($tmp, $contents);
rewind($tmp);
$result = ftp_fput($ftp_stream, $remote_file, $tmp, $mode, $startpos);
fclose($tmp);
return
$result;
}
?>

<< Back to user notes page

To Top