asihttprequest上傳文件
- NSString *fileName = [[NSBundle mainBundle] pathForResource:@"test"ofType:@"jpg"];
- NSString *url = @"http://....../upload.aspx";
- ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL: [NSURL URLWithString: url]];
- [request setPostValue: @"MyName" forKey: @"name"];
- [request setFile: fileName forKey: @"this_is_file"];
- [request buildRequestHeaders];
- NSLog(@"header: %@", request.requestHeaders);
- [request startSynchronous];
- NSLog(@"responseString = %@", request.responseString);
歡迎關注本站公眾號,獲取更多信息