1.
RootViewController.m
#import "RootViewController.h" #define URL @"http://localhost:8080/TestOne/upload3.jsp" @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100, 100, 100, 50); [button setTitle:@"发送图片" forState:0]; button.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:button]; [button addTarget:self action:@selector(postImageAction:) forControlEvents:7]; } -(void)postImageAction:(UIButton *)sender { //分界线的标示符,用于区分每一条 NSString *TWITTERFO_FORM_BOUNDARY = @"AaB03x"; //根据url初始化request NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:URL] cachePolicy:NSURLRequestReloadIgnoringCacheData