php 发送与接收流文件
来源:互联网 发布:尚观linux 百度网盘 编辑:程序博客网 时间:2024/05/17 09:45
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; }<span style="color:#ff0000;"></span> 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数据蹲
- sobel边缘检测算子
- android Sqlite 模板 。
- 手动加载应用上下文无法自动终结的解决办法
- cvEvalCARTClassifier
- 不指定输入数据个数,和memcpy函数
- php 发送与接收流文件
- C语言----指针
- CF 6B President's Office
- zookeeper 安装
- In与Exists的区别
- HDR 拍照模式的原理,实现及应用
- 成为一个人3
- 论文提要“Gradient based Learning Applied to Document Reocognition”
- 随机产生一些数字但是数字不能重复