使用AFNetworking将文件上载到我的apache服务器

使用AFNetworking将文件上载到我的apache服务器,apache,http,post,upload,afnetworking,Apache,Http,Post,Upload,Afnetworking,我使用afnetworking将文件上传到apache。在此之前,我将apache服务器配置为 我的上传代码是: NSString *remoteUrl = @"http://192.168.8.101/example"; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"uploadPic" ofType:@"JPG"]; NSMutableURLRequest *request = [[AFHTTPRequestSer

我使用afnetworking将文件上传到apache。在此之前,我将apache服务器配置为 我的上传代码是:

NSString *remoteUrl = @"http://192.168.8.101/example";
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"uploadPic" ofType:@"JPG"];
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:remoteUrl parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    [formData appendPartWithFileURL:[NSURL fileURLWithPath:filePath] name:@"file" fileName:filePath.lastPathComponent mimeType:@"image/jpeg" error:nil];
} error:nil];

AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSProgress *progress = nil;

NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"succ:%@ %@", response, responseObject);
    }
}];
[uploadTask resume];
NSString*remoteUrl=@”http://192.168.8.101/example";
NSString*文件路径=[[NSBundle mainBundle]路径用于资源:@“uploadPic”,类型:@“JPG”];
NSMutableURLRequest*request=[[AFHTTPRequestSerializer]multipartFormRequestWithMethod:@“POST”URLString:remoteUrl参数:nil constructingBodyWithBlock:^(id formData){
[formData appendPartWithFileURL:[NSURL fileURLWithPath:filePath]名称:@“文件”文件名:filePath.lastPathComponent mimeType:@“图像/jpeg”错误:无];
}错误:无];
AFURLSessionManager*manager=[[AFURLSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
manager.responseSerializer=[AFHTTPResponseSerializer序列化程序];
NSProgress*进度=零;
NSURLSessionUploadTask*uploadTask=[manager uploadTaskWithStreamedRequest:请求进度:&进度完成处理程序:^(NSURLResponse*响应,id responseObject,NSError*错误){
如果(错误){
NSLog(@“错误:%@”,错误);
}否则{
NSLog(@“成功:%@%@”,响应,响应对象);
}
}];
[上传任务恢复];
我收到了状态码200

2014-06-08 16:13:18.760 ReasearchDemo[10374:60b] succ:<NSHTTPURLResponse: 0x17803b240> { URL: http://192.168.8.101/example/ } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Length" = 1322;
"Content-Type" = "text/html;charset=ISO-8859-1";
Date = "Sun, 08 Jun 2014 08:13:17 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.4.7 (Unix) PHP/5.5.6 OpenSSL/1.0.1e mod_perl/2.0.8-dev Perl/v5.16.3";
2014-06-08 16:13:18.760重新搜索演示[10374:60b]成功:{URL:http://192.168.8.101/example/ }{状态代码:200,标题{
连接=“保持活动”;
“内容长度”=1322;
“内容类型”=“文本/html;字符集=ISO-8859-1”;
日期=“太阳,2014年6月8日08:13:17 GMT”;
“保持活动”=“超时=5,最大=100”;
Server=“Apache/2.4.7(Unix)PHP/5.5.6 OpenSSL/1.0.1e mod_perl/2.0.8-dev perl/v5.16.3”;
问题是我找不到我上传的文件这意味着我上传失败,但我不知道问题所在
任何人都可以帮忙 非常感谢