Can you post the html?
API uses newlines as a delimiter, so at a minimum, you will need to strip newlines from the html.
There may be other common html characters that need escaping as well.
I should have written: "My version of the php api class uses newlines as a delimiter....I changed that."
I then tried this:
test.html
<html>
<head>
<title>Login</title>
</head>
<body>
<div id="test">test</div>
</body>
</html>
test.php
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
if ($API->connect('<ip>','admin','<password>')) {
$text = file_get_contents('test.html');
echo $text;
$API->write('/file/set',false);
$API->write('=.id=test.txt',false);
$API->write("=contents=" . $text);
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
print_r($ARRAY);
$API->disconnect();
}
?>
On RB, after running test.php, test.txt looks like:
<html>
<head>
<title>Login</title>
</head>
<body>
<div id="test">test</div>
</body>
</html>
Works perfectly.