delphi webservices传文件


本文整理自网络,侵删。

 webservices传文件

有两种方法,一种是把二进制对象转成base64码,返回字符串,应该是最简单的方法,另外一种就是返回二进制数组TByteArray
服务器:
function TFileSoap.getPic(out size:integer): TByteArray;
var
buf:TMemoryStream;
begin
try
    if not FileExists('c:\1.bmp') then
      raise Exception.Create('file not found.');
 
    buf:=TMemoryStream.create;
    buf.LoadFromFile('c:\1.bmp');
    size:=buf.Size;
    setlength(result,size);
    move(buf.Memory^,result[0],size);
finally
    buf.free;
end;
end;
客户端
procedure TForm1.Button1Click(Sender: TObject);
var
size:integer;
buf:TMemoryStream;
ary:TByteArray;
begin
buf:=TMemoryStream.create;
try
    ary:=GetIFileSoap.getPic(size);
    buf.SetSize(size);
    move(ary[0],buf.memory^,size);
    Image1.Picture.Bitmap.LoadFromStream(buf);
finally
    buf.free;
end;
end;

相关阅读 >>

Delphi程序不受windows日期格式的影响

Delphi 将整数转换为罗马数字

Delphi 获取网卡信息

Delphi 使用indy idftp 通过android 上传文件

Delphi tpath.combine(); {结合路径}

Delphi 创建大窗口

Delphi创建密钥文件

Delphi 判断是否是系统管理员身份

Delphi tcombobox 设置默认值

Delphi 提取字符串中所有数字

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...