dongshu4755 2014-12-29 20:20
浏览 91
已采纳

如何从客户端向服务器发送数据

I'm trying to write a server, which can download files in a piece-wise manner. So, if the connection is interrupted, next time the same client connects, the download can resume from where it stopped.

Now, suppose when the client opens the webpage, the server starts reading files saved on it, in the following manner:

$handle = fopen($file_in, "rb");
$handle_2 = fopen($file_out, "w");
$contents = fread($handle, filesize($file_in));
fwrite($handle_2, $contents);

Of course, the fwrite won't work with files on the client's computer.

So basically my question is, how do I send data to a file on the client's pc, once I have the file contents?

  • 写回答

1条回答 默认 最新

  • dongzhi5587 2014-12-30 23:06
    关注

    The HTTP_Download PEAR package seems to be what you are looking for:

    HTTP_Download provides an interface to easily send any arbitrary data to HTTP clients. HTTP_Download can gain its data from variables, files or stream resources.

    With this package you can easily handle (hidden) downloads. Hidden means not accessible by the public - for instance if you want to restrict access to particular downloads.

    It supports HTTP compression, caching and partial downloads, resuming and sending raw data, for example from database BLOBs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据