<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Aug 23, 2014 at 3:12 PM, "Leonardo M. Ramé" <span dir="ltr"><<a href="mailto:l.rame@griensu.com" target="_blank">l.rame@griensu.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi, I'm trying to translate this PHP code to fcl-web (actually brookframework):<br>


<br>
<?php<br>
$content = file_get_contents('php://<u></u>input');<br>
$fh = fopen('output.wav', 'w') or die("can't open file");<br>
fwrite($fh, $content);<br>
fclose($fh);<br>
?><br>
<br>
The difficult part is the line with "file_get_contents('php://<u></u>input')", it contains the whole POST content as binary.<br>
<br>
What I already did was this:<br>
<br>
procedure TActAudio.Post;<br>
var<br>
  lWav: TMemoryStream;<br>
begin<br>
  lWav := TMemoryStream.Create;<br>
  try<br>
    lWav.Write(HttpRequest.<u></u>Content[1], HttpRequest.ContentLength);<br>
    lWav.Position:= 0;<br>
    lWav.SaveToFile('/tmp/output.<u></u>wav');<br>
  finally<br>
    lWav.Free;<br>
  end;<br>
end;<br>
<br>
But the output.wav result is corrupt, while the php one is correct.<br>
<br>
Any hint?.<br>
<br>
Regards,<br></blockquote><div><br></div><div>Worked fine here:</div><div><br></div><div><div>procedure TMyAction.Post;</div><div>begin</div><div>  with TFileStream.Create('out.txt', fmCreate) do</div><div>  try</div>

<div>    Write(TheRequest.Content[1], TheRequest.ContentLength);</div><div>  finally</div><div>    Free;</div><div>  end;</div><div>end;</div></div><div><br></div><div><div>POST /<a href="http://cgi1.br">cgi1.br</a> HTTP/1.1</div>

<div><br></div><div>{"key1":"value1","key2":"value2"}</div></div><div><br></div><div>out.txt:</div><div>{"key1":"value1","key2":"value2"}<br>

</div><div><br></div><div>Or:</div><div><br></div><div><div>procedure TMyAction.Post;</div><div>begin</div><div>  with TMemoryStream.Create do</div><div>  try</div><div>    Write(TheRequest.Content[1], TheRequest.ContentLength);</div>

<div>    SaveToFile('post.txt');</div><div>  finally</div><div>    Free;</div><div>  end;</div><div>end;</div></div><div><br></div><div>P.S.: php://input is not available with enctype="multipart/form-data".</div>

<div><br></div></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>