I am trying to send an audio file to my server using AFNetworking but so far without success. This is the code on my device:
self.manager = [AFHTTPRequestOperationManager manager];
[self.manager POST:@"upload.php"
parameters:@{}
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:self.output.soundData name:@"audio" fileName:@"recordedSound.m4a" mimeType:@"audio/m4a"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
This is my code on the server:
<?php
define("WWW_ROOT",dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR);
if (!empty($_FILES)) {
$target_path = WWW_ROOT ."uploads/";
$target_path = $target_path . basename( $_FILES['audio']['name']);
move_uploaded_file($_FILES['audio']['tmp_name'], $target_path);
}
Whenever I try to send the data to the server, I get this error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -streamStatus only defined for abstract class. Define -[AFMultipartBodyStream streamStatus]!'