php - $_FILES is always empty -
i uploading pdf server through web-service, $_files seems empty regardless of do.
the program uploading pdf osx program (via afnetworking). have ruled out possibility of causing issue when attempt upload file through 'cocoarestclient' (similar postman on chrome) nothing. in cocoarestclient setting contenttype 'multipart/form-data'.
the pdf attempting upload 478kb not think size issue.
my php code below. @ moment trying see if in $_files array @ all.
<?php header('content-type: multipart/form-data'); $filename = $_files['pdf']['name']; $tmpname = $_files['pdf']['tmp_name']; $filesize = $_files['pdf']['size']; $filetype = $_files['pdf']['type']; $response = array("filename" => $filename, "tmpname" => $tmpname, "filesize" => $filesize, "filetype" => $filetype, "files" => $_files); echo json_encode($response); ?>
this response json
{"filename":null, "tmpname":null, "filesize":null, "filetype":null, "files":[]}
this objective-c code.
[manager post:pdfurl parameters:nil constructingbodywithblock:^(id <afmultipartformdata> formdata) { [formdata appendpartwithfiledata:pdf name:@"pdf" filename:filename mimetype:@"multipart/form-data"]; } success:^(nsurlsessiondatatask *operation, id responseobject) { [self checkforerrorinresponse:responseobject]; [delegate pdfuploadedsuccessfullywithresponse:responseobject]; } failure:^(nsurlsessiondatatask *operation, nserror *error) { [delegate pdffailedtouploadwitherror:error]; }];
after using postman determine php working correctly, can conclude objective-c code causing bug. strange however, though php code returns null's, charles telling me pdf being uploaded!
found solution! problem wasn't setting request serializers http header field 'application/pdf'.
[manager.requestserializer setvalue:@"application/pdf" forhttpheaderfield:@"content-type"];
Comments
Post a Comment