[Lazarus] Translating php://input into fcl-web
"Leonardo M. Ramé"
l.rame at griensu.com
Sat Aug 23 20:12:02 CEST 2014
Hi, I'm trying to translate this PHP code to fcl-web (actually
brookframework):
<?php
$content = file_get_contents('php://input');
$fh = fopen('output.wav', 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
?>
The difficult part is the line with "file_get_contents('php://input')",
it contains the whole POST content as binary.
What I already did was this:
procedure TActAudio.Post;
var
lWav: TMemoryStream;
begin
lWav := TMemoryStream.Create;
try
lWav.Write(HttpRequest.Content[1], HttpRequest.ContentLength);
lWav.Position:= 0;
lWav.SaveToFile('/tmp/output.wav');
finally
lWav.Free;
end;
end;
But the output.wav result is corrupt, while the php one is correct.
Any hint?.
Regards,
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
More information about the Lazarus
mailing list