目录结构
![img](http://ww1.sinaimg.cn/mw690/78f9859egw1evaczvpnwfj207k0dtmyy.jpg)
iOS主要程序
![img](http://ww1.sinaimg.cn/mw690/78f9859egw1evaczv0po3j20xi07ydjt.jpg)
NSString* path = [[NSBundle mainBundle] pathForResource:@"sophie" ofType:@"mov"];
NSLog(@"path is %@",path);
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://192.168.66.137/RemoteVideo/WebForm1.aspx"]];
[request addFile:path forKey:@"video"];
[request addPostValue:@"sophie" forKey:@"filename"];
[request setCompletionBlock:^{
NSLog(@"%@",request.responseString);
}];
[request setFailedBlock:^{
NSLog(@"asi error: %@",request.error.debugDescription);
}];
[request startAsynchronous];
服务端完整代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RemoteImage
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Files.Count == 0)
{
Response.Write("none file");
}
else
{
HttpPostedFile file = Request.Files["video"];
String filename = Request.Form["filename"];
file.SaveAs(MapPath("~/" + filename + ".mov"));
Response.Write("ok");
}
}
}
}
测试结果
![img](http://ww3.sinaimg.cn/mw690/78f9859egw1evad25yki9j20by057jrx.jpg)