转载自 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. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(48)-工作流设计-起草新申请

    原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(48)-工作流设计-起草新申请 系列目录 创建新表单之后,我们就可以起草申请了,申请按照严格的表单步骤和分 ...

  2. JSON 数据的系统解析

    - (IBAction)jsonSystemButtonDidClicked:(UIButton *)sender { self.JSONArray = [NSMutableArray array]; ...

  3. c++ timer基于win消息队列

    能够承载10w个timer通信执行,说关闭就关闭,里面用了一个比較巧妙的线程处理,呵呵10W个timer就10多个线程,请大牛不要笑话,供新手学习之用 #pragma once #include &l ...

  4. 安装在ubuntu12.04上安装gcc4.8

    因为gcc4.8支持最新的c++11标准,所有开始c++11标准系列学习前,请按照gcc4.8,方便边学习边写代码练习. 安装编译好的gcc4.8 sudo add-apt-repository pp ...

  5. linux内核学习-建议路线

    三大经典书: LDD: Linux Device Driver 容易上手 LKD: Linux Kernel Development 通俗易懂 UDK: Understand Linux Kernel ...

  6. IOS的工程目录结构和生命周期

    IOS的工程目录结构和生命周期 ·simple table文件夹:工程相关源代码和配置文件 BIDAppDelegate :    委托的声明和实现 BIDViewController:    视图控 ...

  7. Java基础知识强化之集合框架笔记29:使用LinkedList实现栈数据结构的集合代码(面试题)

    1. 请用LinkedList模拟栈数据结构的集合,并测试:  题目的意思是:     你自己的定义一个集合类,在这个集合类内部可以使用LinkedList模拟,使用LinkedList功能方法封装成 ...

  8. Android Studio安装及首次运行遇到的问题

    Android Studio,下载地址:http://developer.android.com/sdk/index.html.需要注意的是Android Studio需要JDK 1.7+才可以安装, ...

  9. URL编码 URLEncoder 示例

    2016-12-27 对字符编码时的规则 通常如果一样东西需要编码,说明这样东西并不适合传输.原因多种多样,如Size过大,包含隐私数据. 对于Url来说,之所以要进行编码,一个是因为Url中有些字符 ...

  10. sql语句游标的写法

    当循环查找一张表的信息时,我们得写一张游标来对每条信息进行操作,具体格式如下 DECLARE @fitemid int DECLARE #point_cursor CURSORFORSELECT fi ...