http - use AFNetworking upload file to my apache server -
i use afnetworking upload file apache . before config apache server this , upload code is:
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];
and received status code 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";
the problem can not find file upload means upload fail don't know problem
can lot
Comments
Post a Comment