Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

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


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:


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 = @"" 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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How can I use openCV to recognize a card? BarryK88 iPhone/iPad Programming 2 Sep 26, 2011 04:18 AM
How to keep data without the app? Kuzminator iPhone Tips, Help and Troubleshooting 0 Jun 3, 2011 11:19 PM
How can I place an image behind an imageView. BarryK88 iPhone/iPad Programming 0 Apr 15, 2011 03:14 AM
Two computers, how can I get Mail to not download messages from server? wwooden Mac Applications and Mac App Store 12 Aug 12, 2009 05:35 PM
How can I change image size of photos on the Mac? markw10 Mac Applications and Mac App Store 2 May 14, 2007 03:40 AM

All times are GMT -5. The time now is 10:11 AM.

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

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