Translate

2016年2月23日 星期二

post image


NSData *imageData = UIImageJPEGRepresentation(self.image.image,0);
NSString *url=@"http://test/postimage";

 NSURL *theURL = [NSURL URLWithString:url];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:8.0f];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [theRequest setValue:@"image/jpg" forHTTPHeaderField:@"Content-Type"];
    theRequest.timeoutInterval=10.0;
    [theRequest setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[imageData length]] forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPBody: imageData];
    
    NSString *result= [self HttpResult:theRequest];
    

沒有留言:

張貼留言