Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-29-2008, 11:24 PM   #15 (permalink)
BostonMerlin
Lost in a sea of code
 
BostonMerlin's Avatar
 
Join Date: Apr 2008
Location: Boston
Posts: 399
Default

Uprise, what did you use to base64 encode?

thanks
john



Quote:
Originally Posted by uprise78 View Post
Client side code. Message was base64 encoded before being

sent to this function.

Code:
- (void)sendSerializedGreeting:(NSString *)message
{
	// Show a loading indicator
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
	
	NSString *greetingURL = [NSString stringWithFormat:@"http://yourwebsite.com", [[UIDevice currentDevice] uniqueIdentifier]];
	NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:greetingURL]
															  cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];	
	
	NSDictionary *headerFieldsDict = [NSDictionary dictionaryWithObjectsAndKeys:@"text/xml; charset=utf-8", @"Content-Type", nil];
	
	[theRequest setHTTPBody:[message dataUsingEncoding:NSUTF8StringEncoding]];
	[theRequest setAllHTTPHeaderFields:headerFieldsDict];
	[theRequest setHTTPMethod:@"POST"];
	
	// create the connection with the request and start loading the data
	NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
	
	if (theConnection == nil)
	{
		NSLog(@"Failed to create the connection");
	}
}
Server side code:
// PHP
Code:
$file = base64_decode(file_get_contents("php://input"));
// ASP
Code:
StreamReader sr = new StreamReader(Page.Request.InputStream);
string file = Encoding.ASCII.GetString(Convert.FromBase64String(sr.ReadToEnd()));
__________________
----------------------------------------------------------------------
I love being a dad, flying airplanes and writing code.
----------------------------------------------------------------------
Follow me on Twitter: @BostonMerlin
Feed your brain on Twitter: @iPhoneDev101
----------------------------------------------------------------------
iPhone Apps:
BostonMerlin is offline   Reply With Quote
 

» Advertisements
» Online Users: 800
25 members and 775 guests
ADY, cinquiemeas, ckgni, dabvid, Desert Diva, dfvdan, GFish, GHuebner, ilmman, iph_s, joeallenpro, john love, keeshux, marcelglaeser, marto1914, Ndpiparava, nfung, nru, RoryHarvey, supasounds, tomtom100, VikMyr, waq963, _Mac
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,868
Threads: 89,225
Posts: 380,692
Top Poster: BrianSlick (7,129)
Welcome to our newest member, stokesreece
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:30 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.