I am developing an app that sends data to a webservice. The data transfered uses https messages with POST method.
On the server side, in PHP i wrote code that takes data from the POST message (as long as data is a string),
by using technique as follows.
$servercall = $_POST['servercall'];
Issue i have now found is how do i read data when i transmit multipart/form-data.
In objective-c i construct the http message as follows.
NSURL *url = [NSURL URLWithString:@"<ADDRESS>"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"gc0p4Jq0M2Yt08jU534c0p";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"
--%@
", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"photo\"; filename=\"%@.jpg\"
", @"teacherimage"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream
" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:Array.picture]];
[body appendData:[[NSString stringWithFormat:@"
--%@
", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"message\"
%@", postSTRING] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"
--%@
", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
how do i read the photo and textstring in the http message in PHP? I dont even know the technique for me to google.
If it makes any difference all data is being saved in SQL database.
Thanks