目录结构
iOS主要程序
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");
}
}
}
}
测试结果