faustomen
asked on
How can I send a MemoryStream to a cgi application ?
Hi,
I am using Tidhttp.post('www.host.com/my.cgi',Image_in_MemoryStream) to send an image to cgi application.
How can I put this image in a memory stream variable in the cgi application (my.cgi)?
Thanks
I am using Tidhttp.post('www.host.com/my.cgi',Image_in_MemoryStream) to send an image to cgi application.
How can I put this image in a memory stream variable in the cgi application (my.cgi)?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi luwo,
I need to use a Delphi cgi application to receive image.
My client application is ready to send the image (using IdHTTP1.Post) but I dont know how to transfer the stream (from client application) to a variable MemoryStream in the cgi application.
Thanks
I need to use a Delphi cgi application to receive image.
My client application is ready to send the image (using IdHTTP1.Post) but I dont know how to transfer the stream (from client application) to a variable MemoryStream in the cgi application.
Thanks
faustomen:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
to accept luwo's answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
kacor
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area for this question:
to accept luwo's answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
kacor
EE Cleanup Volunteer
hi fausomen, maybe this works:
//1x idhttp-component,
//1x Memo-component
procedure TForm1.Button1Click(Sender
var src,cont,tmp:Tmemorystream
ds,boundary:string;
//helping procedure to write string with linefeed...
procedure wr(const txt:string);
var ds:string;
begin
ds:=txt+#13#10;
src.Write(ds[1],length(ds)
end;
begin
src :=Tmemorystream.Create;
cont :=Tmemorystream.Create;
boundary:='---------------
//your http-content-type is multipart
idhttp1.Request.ContentTyp
//the binary-file:
wr('--'+boundary);
wr('Content-Disposition: form-data; name="userfile"; filename="C:\originalfilen
wr('Content-Type: application/octet-stream')
wr('');
//integrate the bin-data...
tmp:=tmemorystream.Create;
tmp.LoadFromFile('c:\binar
tmp.seek(0,0); src.CopyFrom(tmp,tmp.size)
tmp.free;
wr(''); //last-linefeed is absolutely necessary!
//close your multipart...
wr('--'+boundary+'--');
wr('');
IdHTTP1.Post('http://www.host.com/response.php?var1=content1',src,cont);
cont.seek(soFromBeginning,
memo1.Lines.LoadFromStream
src.free;
cont.free;
end;
//your response.php-file could be like this:
<?
$tmpfilename=$_FILES["user
$orgfilename=$_FILES["user
system('cp '.$tmpfilename.' /tmp/'.$orgfilename);
/*
the structure of _$FILES["blalaber"] is
Array
(
[name] => testfile.zip
[type] => application/x-zip-compress
[tmp_name] => /tmp/phppZxrmP
[error] => 0
[size] => 29868
)
*/
?>
---------------
hope, this is what r you searching for...
luwo