php 发送与接收流文件
来源:互联网 发布:vivo授权网络怎么弄 编辑:程序博客网 时间:2024/04/30 12:39
php 发送与接收流文件
sendStreamFile.php 把文件以流的形式发送
receiveStreamFile.php 接收流文件并保存到本地
sendStreamFile.php
<?php/** php 发送流文件* @param String $url 接收的路径* @param String $file 要发送的文件* @return boolean*/function sendStreamFile($url, $file){ if(file_exists($file)){ $opts = array( 'http' => array( 'method' => 'POST', 'header' => 'content-type:application/x-www-form-urlencoded', 'content' => file_get_contents($file) ) ); $context = stream_context_create($opts); $response = file_get_contents($url, false, $context); $ret = json_decode($response, true); return $ret['success']; }else{ return false; }}$ret = sendStreamFile('http://localhost/fdipzone/receiveStreamFile.php', 'send.txt');var_dump($ret);?>
receiveStreamFile.php
<?php/** php 接收流文件* @param String $file 接收后保存的文件名* @return boolean*/function receiveStreamFile($receiveFile){ $streamData = isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : ''; if(empty($streamData)){ $streamData = file_get_contents('php://input'); } if($streamData!=''){ $ret = file_put_contents($receiveFile, $streamData, true); }else{ $ret = false; } return $ret;}$receiveFile = 'receive.txt';$ret = receiveStreamFile($receiveFile);echo json_encode(array('success'=>(bool)$ret));?>
源码下载地址:点击查看
0 0
- php 发送与接收流文件
- php 发送与接收流文件
- php 发送与接收流文件
- php 发送与接收流文件
- php发送与接收流文件的方法
- php发送与接收流文件的方法
- linux网络编程----发送与接收文件
- 利用UDP协议发送与接收文件
- C# 超大文件发送与接收
- Smack+Openfire 文件接收与发送
- C# socket 发送接收消息与发送接收文件 群发文件
- php模拟post向WebService发送内容及接收文件
- PHP SCOKET发送大文件,接收端JAVA
- MFC - 文件发送接收
- tcp 发送接收文件
- PHP主动发送与被动接收xml数据
- PHP主动发送与被动接收xml数据褂
- PHP主动发送与被动接收xml数据蹲
- 柴静辞职原因vvstdj5258
- 求二叉树的先序遍历
- 浅析Java虚拟机结构与机制
- 【原创】PHP程序员的技术成长规划
- 时间和事件,收入和支出
- php 发送与接收流文件
- Fragment 点点滴滴
- UVA - 110 Meta-Loopless Sorts
- lwIP配置文件opt.h和lwipopts.h初步分析
- 数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历
- hdfs namenode -format报错
- Qt5 Qml import folder and qrc problem
- Android NDK inline函数只有第一个实例化的会生效
- JAVA语言用于做算法