objective c - PHP empty TMP_NAME on iOS Upload Image -


i developing ios project requests user upload image server.

i have code in class in objective-c:

        nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init];         [request sethttpshouldhandlecookies:no];         [request settimeoutinterval:60];         [request sethttpmethod:@"post"];         nsstring *boundary = @"------vohpleboundary4quqlum1ce5lmwcy";         nsstring *contenttype = [nsstring stringwithformat:@"multipart/form-data; boundary=%@", boundary];         [request setvalue:contenttype forhttpheaderfield: @"content-type"];          nsmutabledata *body = [nsmutabledata data];         nsmutabledictionary *parameters = [[nsmutabledictionary alloc] init];         [parameters setvalue:[sskeychain passwordforservice:@"id" account:@"spotterbike"] forkey:@"id"];          (nsstring *param in parameters) {             [body appenddata:[[nsstring stringwithformat:@"--%@\r\n", boundary] datausingencoding:nsutf8stringencoding]];             [body appenddata:[[nsstring stringwithformat:@"content-disposition: form-data; name=\"%@\"\r\n\r\n", param] datausingencoding:nsutf8stringencoding]];             [body appenddata:[[nsstring stringwithformat:@"%@\r\n", [parameters objectforkey:param]] datausingencoding:nsutf8stringencoding]];         }          nsstring *fileparamconstant = @"uploadedfile";         nsdata *imagedata = uiimagejpegrepresentation(image, 1);          if (imagedata){             [body appenddata:[[nsstring stringwithformat:@"--%@\r\n", boundary] datausingencoding:nsutf8stringencoding]];             [body appenddata:[[nsstring stringwithformat:@"content-disposition: form-data; name=\"%@\"; filename=\"image.jpg\"\r\n", fileparamconstant] datausingencoding:nsutf8stringencoding]];             [body appenddata:[@"content-type:image/jpeg\r\n\r\n" datausingencoding:nsutf8stringencoding]];             [body appenddata:imagedata];             [body appenddata:[[nsstring stringwithformat:@"\r\n"] datausingencoding:nsutf8stringencoding]];         }          [body appenddata:[[nsstring stringwithformat:@"--%@--\r\n", boundary] datausingencoding:nsutf8stringencoding]];         [request sethttpbody:body];         [request seturl:[nsurl urlwithstring:@"http://212.92.57.155/app/uploadimage.php"]]; 

however, although server recieves image, not able process further usage in it. see, tmp_name empty, not able move image directory.

print_r($_files['uploadedfile']);  (     [name] => image.jpg     [type] =>      [tmp_name] =>      [error] => 1     [size] => 0 ) 

any idea of why happening?

the image file size of photos taken using camera tend quite large 3g connection. therefore, answer suggests, need increase max_request_timeout


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -