-(void) Upload_attach: (NSData *) data filename: (NSString *) filename mimeType: (NSString *) Mtype {
Afhttpclient *httpclient;
Mbprogresshud *hud = [[Mbprogresshud alloc] initWithView:self.view];
[Tool showhud:nslocalizedstring (@ "uploading", nil) AndView:self.view Andhud:hud];
NSString *userid = [[Config Instance] getusername];
Nsarray *userid_arr = [UserId componentsseparatedbystring:@ "_"];
NSString *username = [Userid_arr objectatindex:0];
NSString *company_id = [Userid_arr objectatindex:1];
Nsdictionary *para = [nsdictionary dictionaryWithObjectsAndKeys:self.groupName, @ "GroupName", username,@ "username", company_id, @ "company_id", filename, @ "filename", nil];
NSLog (@ "para:%@", para);
NSString *serveraddr = [Config instance].getservaddr;
NSString *upload_path = [NSString stringwithformat:@ "%@/index.php/ofctrl/upload_attach", BasePath];
Nsurl *url = [Nsurl urlwithstring:serveraddr];
HttpClient = [[Afhttpclient alloc] initwithbaseurl:url];
Nsmutableurlrequest *request = [httpClient multipartformrequestwithmethod:@ "POST" Path:upload_path Parameters:para constructingbodywithblock:^ (id<afmultipartformdata> formData) {
[FormData appendpartwithfiledata:data name:@ "UploadFile" Filename:filename mimetype:@ "Image/png"];
}];
[Request settimeoutinterval:30];
Afhttprequestoperation *op = [[Afhttprequestoperation alloc] initwithrequest:request];
[Op setcompletionblockwithsuccess:^ (afhttprequestoperation *operation, id responseobject) {
NSLog (@ "Upload success!%@", (NSString *) responseobject);
[HUD Hide:yes];
[Self loaddata];
} failure:^ (Afhttprequestoperation *operation, Nserror *error) {
NSLog (@ "Upload failed:%@", error);
[HUD Hide:yes];
}];
[Httpclient.operationqueue Addoperation:op];
[op start];
The};===== corresponding PHP receive parameter is an array (
' UploadFile ' =
Array (
' Name ' = ' 20150128163845.png ',
' Type ' = ' image/png ',
' Tmp_name ' = ' c:\\windows\\temp\\php70.tmp ',
' ERROR ' = 0,
' Size ' = 12767720,
),
afnetworking Send image analysis