Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post an image to the web services
    primarykey
    data
    text
    <p>In my project:-</p> <p>1)click a picture from camera(don't save it).</p> <p>2)show a cropped image with 2 buttons post and cancel.where post button post the image and cancel button discard the image.it looks something like this. <img src="https://i.stack.imgur.com/099QK.png" alt="2nd"></p> <p>I don't know how to post the camera capture image.I searched over the internet find a lot of codes but didn't find any code that helps me out.</p> <p>I tried code given on these links..</p> <p><a href="http://www.iriphon.com/2011/11/09/ios-uploading-an-image-from-your-iphone-to-a-server/" rel="nofollow noreferrer">First</a> ,<a href="http://code.developwithus.com/iphone/upload-image-and-data-with-iphone-sdk/" rel="nofollow noreferrer">Second</a> ,<a href="https://stackoverflow.com/questions/5319823/newbie-having-issues-with-uploading-a-file-using-asihttprequest">Third</a>, and many others.</p> <p>I wish someone will help..how to post?? thanks.</p> <pre><code>-(IBAction)sendRequest:(id)sender { #define DataDownloaderRunMode @"myapp.run_mode" NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60]; [request setHTTPMethod:@"POST"]; NSString *boundary = @"----WebKitFormBoundarycC4YiaUFwM44F6rT"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name="attachment[file]"; filename="picture.png"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: image/png\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imageData]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:body]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO]; [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:DataDownloaderRunMode]; [connection start]; } </code></pre> <p>and connecting this to post button..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload