I am having an app in which I am uploading some data to web server.
Here is the code that I got from the links from google.
UIImage * img = [UIImage imageNamed:@"register_btn.png"];
NSData *imageData = UIImageJPEGRepresentation(img, 90);
NSString *urlString = @"http://tes.in/testservices/User.php";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"------------------------1473780983146499882746641449";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"
--%@r
", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data;filename=\a.jpg\"
"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Type: application/json
"]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"
--%@--
",boundary]dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString =[[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
//profile_photo_link
NSLog(@"%@",returnString);
But I am not getting what exactly I need to pass here in the code.
My parameter for photo upload is "photo_link". I have given the link for php webservice.
I know there are lots of questions on this but I don't know where to pass my parameters and how to check the request string.
If possible please anyone can give me the code for PHP to decode image.
Please help me.
Thanks in advance.