IOS POST 数据,包括文件 到服务器

// Upload a file on disk

NSURL *url = [NSURL URLWithString:@"http://fox.xxx.cn/kids_file/js"];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

//NSFileManager *fileManager = [NSFileManager defaultManager]; 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingFormat:@"/painting/"];

NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"smallerlogo.jpg"];

[request setPostValue:@"xiao fox 高峰君" forKey:@"name"];

[request setPostValue:@"girl" forKey:@"sex"];

[request setFile:writableDBPath withFileName:@"smallerlogo.jpg" andContentType:@"image/jpeg" forKey:@"photo"];

[request setDelegate:self];

[request startAsynchronous];

posted on 2011-09-26 13:20  海南一哥  阅读(101)  评论(0编辑  收藏  举报

导航