转载自 http://www.cnblogs.com/88999660/archive/2013/03/11/2954279.html

如果侵权,请及时通知我删除!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
namespace UpdatePhoto
{
public partial class UpdatePhoto : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string id = Request.Form["id"];
HttpPostedFile hfc = Request.Files["Photo"];
if (hfc == null) return; Stream sm = hfc.InputStream;
byte[] buffer = new byte[sm.Length];
sm.Read(buffer, 0, buffer.Length);
sm.Close(); string path = Request.PhysicalApplicationPath + id + "\\";
//判断路径是否存在
if (!Directory.Exists(path))
{
//如果不存在就创建
Directory.CreateDirectory(path);
}
//产生文件名
string fileName = path + id + "_" + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + "_" + DateTime.Now.Millisecond.ToString() + ".png";
Stream flstr = new FileStream(fileName, FileMode.Create);
BinaryWriter sw = new BinaryWriter(flstr, Encoding.Unicode);
sw.Write(buffer);
flstr.Close();
sw.Close(); }
}
}

client:

using UnityEngine;
using System.Collections; public class updatePhoto : MonoBehaviour { // Use this for initialization
void Start () {
StartCoroutine(ScreenShot());
}
IEnumerator ScreenShot(){
int width = Screen.width;
int height = Screen.height;
// string path = Application.dataPath+"/Resources/";
yield return new WaitForEndOfFrame();
Texture2D tex = new Texture2D(width,height,TextureFormat.RGB24,false);
tex.ReadPixels(new Rect(0,0,width,height),0,0);
//tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] bytes = tex.EncodeToPNG(); WWWForm newForm = new WWWForm(); newForm.AddField("id","123");
newForm.AddBinaryData("Photo",bytes,"photo.jpg"); WWW w = new WWW("http://localhost:36944/UpdatePhoto.aspx", newForm); while (!w.isDone){yield return new WaitForEndOfFrame();} if (w.error != null){Debug.LogError(w.error);}
} }

unity3d中的http通信 二的更多相关文章

  1. unity3d中的http通信

    转载 http://blog.csdn.net/mfc11/article/details/8188785的博客,如果侵权,请留言我及时删除! 前言 Unity3d 是一个跨平台的引擎,在移动互联网浪 ...

  2. 【Unity3D基础教程】给初学者看的Unity教程(五):详解Unity3D中的协程(Coroutine)

    作者:王选易,出处:http://www.cnblogs.com/neverdie/ 欢迎转载,也请保留这段声明.如果你喜欢这篇文章,请点[推荐].谢谢! 为什么需要协程 在游戏中有许多过程(Proc ...

  3. MVVM模式和在WPF中的实现(二)数据绑定

    MVVM模式解析和在WPF中的实现(二) 数据绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...

  4. 【Unity3d游戏开发】Unity3D中的3D数学基础---向量

    向量是2D.3D数学研究的标准工具,在3D游戏中向量是基础.因此掌握好向量的一些基本概念以及属性和常用运算方法就显得尤为重要.在本篇博客中,马三就来和大家一起回顾和学习一下Unity3D中那些常用的3 ...

  5. unity3d中 刚体(Rigidbody) 碰撞体(Collider) 触发器(Is Trigger)

      刚体(Rigidbody)的官方(摘自Unity3d的官方指导书<Unity4.x从入门到精通>)解释如下: Rigidbody(刚体)组件可使游戏对象在物理系统的控制下来运动,刚体可 ...

  6. 转 猫都能学会的Unity3D Shader入门指南(二)

    猫都能学会的Unity3D Shader入门指南(二) 关于本系列 这是Unity3D Shader入门指南系列的第二篇,本系列面向的对象是新接触Shader开发的Unity3D使用者,因为我本身自己 ...

  7. Unity3D中Ragdoll的用法

    一.创建Ragdoll      见unity3d组件文档里的Ragdoll Wizard.由于unity3d中的Ragdoll设置的骨骼点名字与3DMAX里人体骨骼命名有些不一样,下图为Unity3 ...

  8. STUN/TURN/ICE协议在P2P SIP中的应用(二)

    1       说明 2       打洞和穿越的概念... 1 3       P2P中的打洞和穿越... 2 4       使用STUN系列 协议穿越的特点... 2 5       STUN/ ...

  9. Unity3D中的Coroutine详解

    Unity中的coroutine是通过yield expression;来实现的.官方脚本中到处会看到这样的代码. 疑问: yield是什么? Coroutine是什么? unity的coroutin ...

随机推荐

  1. 基于Visual C++2012拆解世界五百强面试题--题3

    请用C语言实现 输入N,打印N*N矩阵 比如 N = 3, 打印: 1 2 3 8 9 4 7 6 5 N = 4, 打印 1   2    3   4 12  13   14  5 11  16   ...

  2. 脚本动态监控input

    Jquery $('input').bind('input propertychange', function() { //进行相关操作 }); JS if(isIE) { document.getE ...

  3. 读取xml时,遇到xmlns的问题

    1.读取xml的时候,由于xml里有xmlns的属性,导致了读xml无法正常读取.通过网上搜索,发现需要先注册命名空间.  xmlns是XML Namespaces的缩写,中文名称是XML(标准通用标 ...

  4. CSS Pseudo-Element Selectors伪对象选择符

    一: CSS3将伪对象选择符(Pseudo-Element Selectors)前面的单个冒号(:)修改为双冒号(::)用以区别伪类选择符(Pseudo-Classes Selectors),但以前的 ...

  5. angularjs kindEditor 中自定义按钮 弹出dialog

    1.angular-kindeditor.js 第38行左右加 editorConfig.items = ["placehoder"]; 2.en.js 第234行 placeho ...

  6. google的西联汇款可以使用工行代收

  7. iOS7初体验(2)——单元测试

    在Xcode 4.6及以前的版本,一直觉得单元测试这部分功能做得很鸡肋,用起来感觉很别扭.这一次Xcode 5.0默认就引入了单元测试,赶快来看看看相比以前的版本有什么提升吧!~_~ 1.     首 ...

  8. MYSQL命令行连接数据库

    连接数据库 mysql -uroot -proot -P3306 -Dmydemo # 参数详解 -uuser 用户user -ppwd 密码 -P3306 端口 -Dmysql 数据库 #显示所有数 ...

  9. 334. Increasing Triplet Subsequence My Submissions Question--Avota

    问题描述: Given an unsorted array return whether an increasing subsequence of length 3 exists or not in ...

  10. TestNG扩展

    1. TestNG API 本章节将讨论如何使用TestNG API来创建自己的TestNG对象.TestNG的API基本由接口组成,这样做是为了容易模拟TestNG返回的对象. 1.1 org.te ...