AFNetworking Uploading a file

First, make sure you have the latest version of AFNetworking downloaded.

AFHTTPRequestOperation +HTTPRequestOperationWithRequest:success:failure: was removed a few versions back. Instead, you can do [[AFHTTPRequestOperation alloc] initWithRequest:...] and then set the completionBlock with either the straight property accessor (operation.completionBlock = ^{...}), or with -setCompletionBlockWithSuccess:failure:. Keep in mind that completion blocks execute after the request has finished downloading.

As for the multipart form block, -appendWithFileData:mimeType:name was also removed a while back. The method you want is -appendPartWithFileData:name:fileName:mimeType:.

Make those two changes and everything should work.

Leave a Comment