使用 FoxPro 下载文件 (HTTP)
今天有人向我寻求有关 FoxPro 问题的帮助,有关如何通过 HTTP 下载文件。
我发现了两件事:一个是付费 ActiveX,另一个是 另一个需要 libcurl。
有没有一种方法可以做到这一点,而不需要任何额外的东西(VFP 8),比如Java中的HttpURLConnection
?例如通过使用 Microsoft.XMLHTTP
Today I was asked for help with a FoxPro issue, about how to download a file via HTTP.
I found two things: one was a paid ActiveX, and the other one requires libcurl.
Is there a way to do that without anything additional (VFP 8), something like HttpURLConnection
in Java? For example by using Microsoft.XMLHTTP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
两个有效的片段,不需要额外的文件/dll/flls/等。
和
(取自此处)
Two snippets that work, and require no additional files/dlls/flls/etc.
and
(taken from here)
是我的
HttpClient.prg
文件(仅支持GET
响应):GET
请求的用法:在上述代码之后执行包含在
m.HttpClient.responseBody
属性中的服务器响应,您可以将值存储到文件中,或者例如将图片存储到 Image 对象的PictureVal
属性中:Is a my
HttpClient.prg
file (onlyGET
response supported):Usage for
GET
requests:After above code is executed server response contained in
m.HttpClient.responseBody
property and you can store value into file or for example for pictures intoPictureVal
property of Image object:考虑使用 West Wind Web Connect。这是一个框架,允许您编写可从 Web 访问的 VFP 应用程序。
Look into using West Wind Web Connect. This is a framework that will allow you to write VFP application that are accessible from the web.
您可以在 VFP 中完成此操作,但需要注册 Windows DLL 以打开连接句柄,并进行调用以获取数据。
另一种选择是使用自动化,例如使用 Internet Explorer。您可以从 VFP 中创建一个 ie 对象,并调用其方法来打开给定的 URL,等待其“就绪状态”完成,然后查看内容。至于试图获取需要URL参数字符串的东西,你可以添加这些没有问题,但如果它需要POST变量,那就要多费点力气了。
正如 Jerry 所提到的,West-Wind 工具非常强大,而且 Rick Strahl 从……我记得大约 1993 年就开始这样做了。他的另一个工具是 wwIPTools.DLL,它提供了更多功能。
You can do it in VFP, but it requires registering the Windows DLLs to open connection handles, and make calls to get data.
Another option is to use automation, such as with Internet Explorer. You can create an ie object from within VFP, and invoke its methods to open a given URL, wait until it's "Ready State" is complete, then look at the content. As for trying to get things that require URL parameter strings, you can add those no problem, but if it requires POST variables, that is a little more effort.
As mentioned by Jerry, the West-Wind tools are quite powerful and Rick Strahl has been doing it since... about 1993 that I remember. His other tool is specifically wwIPTools.DLL that offers even more features.
您还可以查看 Craig Boyd 的免费 VFPConnection 库,他还有一个优秀的免费 JSON 库。
You could also look at Craig Boyd's free VFPConnection library, he also has an excellent free JSON library.
选项 1:
首先确保从缓存中清除文件:
或者在 URL 末尾添加随机参数,例如“?somerandomvalue”。
选项2:
函数的正确使用可以在MSDN上找到。
PS:你错过了这个:http://curl.haxx.se/libcurl/foxpro/
Option 1:
Just make shure to clear the file from the cache first:
Or add a random parameter at the end of the url, like "?somerandomvalue" for example.
Option 2:
The proper use of the functions can be found on MSDN.
PS: You missed this one: http://curl.haxx.se/libcurl/foxpro/