1.index.php

<?php

$data=file_get_contents('./a.jpg');
$opts = array('http' =>
array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\n"
."Content-Length: " . strlen($data) . "\r\n",
// "Authorization: Basic ".base64_encode("$https_user:$https_password")."\r\n",
'content' => $data,
'timeout' => 60
)
); $context = stream_context_create($opts);
$url = 'http://127.0.0.1/testhttpstream/stream.php';
$result = file_get_contents($url, false, $context);
header('Content-type:image/jpg');
echo $result;
?>

2.stream.php

<?php
$data=file_get_contents('php://input');
echo $data;

3.http请求(除get请求)里也有正文,而不是只有请求头而已,php://input获取的就是请求里的正文.

http协议传输二进制数据以及对输入流(php://input)和http请求的理解的更多相关文章

  1. atitit.无损传输二进制数据串传输网络

    atitit.无损传输二进制数据串传输网络 1. gbk的网络传输问题,为什么gbk不能使用来传输二进制数据 1 2. base64 2 3. iso-8859-1  (推荐) 2 4. utf-8  ...

  2. gSoap传输二进制数据

    最近使用gSoap传输二进制数据,遇到问题.gSoap不能一次传输二进制数据.所以使用分包传送. struct xsd_DwgInfo { ];//分包大小 int m_nReadSize;// bo ...

  3. Linux企业级项目实践之网络爬虫(16)——使用base64传输二进制数据

    用http传输二进制的数据时,需要将二进制做一下转化,例如传输的int类型,将int类型之间转为char以后,丢失掉了长度的信息,如数字123456,本来只有4个字节,但是转化成文本的"12 ...

  4. 字符流、字节流、二进制及其在HTTP协议传输

    一.二进制.字节.字符流概念 字(Byte)节是长度单位.位(bit)也是长度单位.计算机通信和存储的时候都是以010101这样的二进制数据为基础的二进制数有两个特点:它由两个基本字符0,1组成,二进 ...

  5. atitit.二进制数据无损转字符串网络传输

    atitit.二进制数据无损转字符串网络传输 1. gbk的网络传输问题,为什么gbk不能使用来传输二进制数据 1 2. base64 2 3. iso-8859-1  (推荐) 2 4. utf-8 ...

  6. 有关使用HTTP协议传输二进制文件

    HTTP协议是基于字符(ASCII)的,当Content-Type项为text/xml,则内容是文本格式:当二进制格式时,Content-Type项为image/gif,就是了.例如,浏览器请求一张图 ...

  7. 转载:【原译】Erlang构建和匹配二进制数据(Efficiency Guide)

    转自:http://www.cnblogs.com/futuredo/archive/2012/10/19/2727204.html Constructing and matching binarie ...

  8. 【转】使用TCP协议连续传输大量数据时,是否会丢包,应如何避免?

    使用TCP协议连续传输大量数据时,是否会丢包,应如何避免? 比如发送文件.记得有人提过可能会发生什么堆栈溢出.怎样避免呢?是不是可以收到数据后发送确认包,收到确认包后再继续发送.或是发送方发送了一些数 ...

  9. [ActionScript 3.0] AS向php发送二进制数据方法之——在URLRequest中构造HTTP协议发送数据

    主类 HTTPSendPHP.as package { import com.JPEGEncoder.JPGEncoder; import com.fylib.httpRequest.HttpRequ ...

随机推荐

  1. Core Animation系列之CADisplayLink

    一直以来都想好好学习下CoreAnimation,奈何涉及的东西太多,想要一次性全部搞定时间上不允许,以后会断断续续的补全.最近项目里用到了CADisplayLink,就顺便花点时间看了看. 一.简介 ...

  2. 算法导论 第六章 思考题 6-3 d叉堆

    d叉堆的实现相对于二叉堆变化不大,首先看它如何用数组表示. 考虑一个索引从1开始的数组,一个结点i最多可以有d个子结点,编号从id - (d - 2) 到 id + 1. 从而可以知道一个结点i的父结 ...

  3. 【LeetCode OJ】Palindrome Partitioning II

    Problem Link: http://oj.leetcode.com/problems/palindrome-partitioning-ii/ We solve this problem by u ...

  4. Include and Require

    The include or require statement takes all the text/codde/markup that exists in the specified file a ...

  5. ios即时通讯客户端开发之-mac上搭建openfire服务器

    一.下载并安装openfire 1.到http://www.igniterealtime.org/downloads/index.jsp下载最新openfire for mac版 比如:Openfir ...

  6. Unity3D内置资源包简介

    Custom Package:倒入第三方的资源包,如果资源包存在中文路径,很容易导入入失败. Character Controller:角色控制相关脚本,第一第三人称的prefab; Glass Re ...

  7. asp.net页面间传值的几种方法

    表单提交 传送页面代码 <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server ...

  8. Python 读书系列

    1. 原文<A byte of Python> 翻译版:<<简明Python教程>> 2. Python:核心编程

  9. python模块的安装

    1.下载所需模块 2.解压到一个目录 3.window下打开cmd 4.切换到模块setup.py目录 5.执行python setup.py install安装 前提是安装了python,并且配置了 ...

  10. ZOJ 3798--解题报告

    题目相关: 3798相关链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5330 Alice和Bob玩数字游戏, 这次Al ...