Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *imageData = [UIImageJPEGRepresentation(_imageView.image, 60) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
- AFHTTPRequestSerializer *serializer = [AFHTTPRequestSerializer serializer];
- NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST"
- URLString:@"http://www.chamreangkhmer.com/api/uploadImage.php" parameters:@{@"image":imageData,@"name":@"Ae2Bs"}
- constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
- } error:nil];
- AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
- manager.requestSerializer = [AFHTTPRequestSerializer serializer];
- manager.responseSerializer = [AFHTTPResponseSerializer serializer];
- AFHTTPRequestOperation *operation =
- [manager HTTPRequestOperationWithRequest:request
- success:^(AFHTTPRequestOperation *operation, id responseObject) {
- NSLog(@"Success %@", operation.responseString);
- } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
- NSLog(@"Failure %@", error.description);
- }];
- [operation setUploadProgressBlock:^(NSUInteger __unused bytesWritten,
- long long totalBytesWritten,
- long long totalBytesExpectedToWrite) {
- NSLog(@"Wrote %lld/%lld, %2.lld%%", totalBytesWritten, totalBytesExpectedToWrite,totalBytesWritten*100/totalBytesExpectedToWrite);
- }];
- [operation start];
Advertisement
Add Comment
Please, Sign In to add comment