pb使用http方式上传下载文件

来源:互联网 发布:淘宝买摩托车哪家可靠 编辑:程序博客网 时间:2024/06/04 19:40

本文通过SATRDA组件几句代码实现文件的http上传和下载,SATRDA提供了文件上传下载功能,包括服务器和客户端的实现。

1. 首先下载SATRDA

下载地址:

http://download.csdn.net/detail/pcwe2002/9620563

最新版本下载,交流请到QQ群:345559891 
2.运行satserver.exe, 完成http服务的启动

3.在server目录下面建立public文件夹,在public文件夹下建立自己目录的文件夹,如file,用于文件上传

准备工作就完成了,上传下载可以参考下文件里面的pb示例.

上传文件代码

long ll_rtn,ll_httpString ls_pathls_path = "d:/xxxx.zip"ll_http = n_api.SATHTTP_Create()n_api.SATHTTP_AddFormFile( ll_http, ls_path, "file/2.zip")ll_rtn = n_api.SATHTTP_PostForm(ll_http,"http://127.0.0.1/upload/file.go")n_api.SATHTTP_Destroy(ll_http)if ll_rtn = 200 then<span style="white-space:pre"></span>messagebox("","成功!")else<span style="white-space:pre"></span>messagebox("",ll_rtn)end if

下载文件代码

long ll_rtn,ll_httpString ls_path,ls_rfilels_rfile = "http://127.0.0.1:5555/file/1.txt"ll_http = n_api.SATHTTP_Create()ll_rtn = n_api.SATHTTP_GetFile(ll_http,ls_rfile,"d:/111.txt")n_api.SATHTTP_Destroy(ll_http)if ll_rtn = 200 thenmessagebox("","成功!")elsemessagebox("",ll_rtn)end if





0 0