Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 2, 2008, 09:48 AM   #1
sspbond007
macrumors member
 
Join Date: Aug 2008
How can I post image (.png) data into the server?

Hi!!!,

I have written an iphone application that requires to upload an image (.png) into the server. But, I do not know how to upload this image data into the server. I found a thread post regarding the upload of image data into the server but actually I do not know how it actually works. Please see this code:

-(void)searchActionUIImage*)theImage
{

UIDevice *dev = UIDevice currentDevice;
NSString *uniqueId = dev.uniqueIdentifier;

UIImage *testImage = UIImage imageNamed:@"image1.png";

NSData * imageData = UIImagePNGRepresentation(testImage);

NSString *postLength = [NSString stringWithFormat:@"%d", imageData length];

NSString *urlString = @"http://example.com/rtl?" stringByAppendingString:@"ve=iPhoneV0&mcid";
urlString = [urlString stringByAppendingString:uniqueId];
urlString = urlString stringByAppendingString:@"&lang=en_US.UTF-8";

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] autorelease;
[request setURL:NSURL URLWithString:urlString];
request setHTTPMethod:@"POST";
request setValueostLength forHTTPHeaderField:@"Content-Length";
request setHTTPBody:imageData;

NSURLConnection *conn=[NSURLConnection alloc] initWithRequest:request delegate:self;
if (conn)
{
receivedData = [NSMutableData data] retain;
}

If this code is working then please tell me how to extract data on the server side so that I can insert image data into a database.

Thanks with warm regards.
sspbond007 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Get pixel data from an image? printz Mac Programming 2 Sep 9, 2013 04:46 PM
Image data from Internet antdawe iPhone 2 Mar 10, 2013 01:13 PM
image data corrupted error hajira iPhone 0 Aug 23, 2012 12:27 AM
System Image Utility on OS X Lion Server paul117 Mac OS X Server, Xserve, and Networking 0 Jun 30, 2012 02:03 AM
NetBoot serve OS 9.2.2 image from Lion Server? Anonymous Freak Mac OS X Server, Xserve, and Networking 4 Jun 7, 2012 06:06 PM

Forum Jump

All times are GMT -5. The time now is 12:19 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC