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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-19-2009, 10:51 AM   #26 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

Thanks for the responses! I'm resigned to setting up my own local http server. Just to see if it will work. Then I can write whatever kind of php script I want. I wrote the correct IPhone code I think to upload the data. My php script was for file handling so I guess what I need is php code to handle the IPhone data and then write that data to a file. The question is, how to I do that? Also, once it's written to a file, how to I download and use that file?
jcafaro10 is offline   Reply With Quote
Old 05-06-2009, 03:53 PM   #27 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

Quote:
Originally Posted by jcafaro10 View Post
Thanks for the responses! I'm resigned to setting up my own local http server. Just to see if it will work. Then I can write whatever kind of php script I want. I wrote the correct IPhone code I think to upload the data. My php script was for file handling so I guess what I need is php code to handle the IPhone data and then write that data to a file. The question is, how to I do that? Also, once it's written to a file, how to I download and use that file?
still looking for some pointers on this, after some unsuccessful searching

Thanks all
jcafaro10 is offline   Reply With Quote
Old 05-11-2009, 11:29 PM   #28 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
funkytaco is on a distinguished road
Question

Quote:
Originally Posted by jcafaro10 View Post
still looking for some pointers on this, after some unsuccessful searching

Thanks all
You can't do this with html. You need to use a scripting language like ASP/PHP.
If you go with PHP, just search for PHPTriad for windows (It's a simple setup executable that adds itself to add/remove area if you decide to remove it).

I already pointed you to fwrite...people even post examples in the user-contributed notes. See previous reply for link.

Example usage:

GET example
http://localhost/webfolder/script.ph...his+is+my+data

use fwrite to write $_GET['data'] to a file. Once you have that working, then try the same with $_POST['data']


How do you download the file? Seriously?
Read the file URL, i.e. http://localhost/webfolder/the_file_i_wrote.php
Have the iPhone pull it's data NSString from an NSURL or from an XmL file if you use an XmL parser.

Last edited by funkytaco; 05-11-2009 at 11:31 PM.
funkytaco is offline   Reply With Quote
Old 05-12-2009, 10:15 AM   #29 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

Quote:
Originally Posted by funkytaco View Post
You can't do this with html. You need to use a scripting language like ASP/PHP.
If you go with PHP, just search for PHPTriad for windows (It's a simple setup executable that adds itself to add/remove area if you decide to remove it).
I already know I need to use PHP. I have PHP installed and everything.

Quote:
Originally Posted by funkytaco View Post
I already pointed you to fwrite...people even post examples in the user-contributed notes. See previous reply for link.
Thanks for the tip, I'll look into fwrite to see what to do.

Example usage:

Quote:
Originally Posted by funkytaco View Post
GET example
http://localhost/webfolder/script.ph...his+is+my+data

use fwrite to write $_GET['data'] to a file. Once you have that working, then try the same with $_POST['data']
I'm not sure I understand this part. GET is what you run on the server to get "this+is+my+data". But what is the data? I'm not trying to just send it some strings, I'm sending it objects from my program.

Quote:
Originally Posted by funkytaco View Post
How do you download the file? Seriously?
Read the file URL, i.e. http://localhost/webfolder/the_file_i_wrote.php
Have the iPhone pull it's data NSString from an NSURL or from an XmL file if you use an XmL parser.
I know how to do download, I had figured that out awhile ago, just upload was confusing.

Thanks
jcafaro10 is offline   Reply With Quote
Old 05-12-2009, 10:35 AM   #30 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

I got fwrite to work. If I do "http://localhost/uploader.php?data=hello" it will write "hello" to a file. Now I'm trying to get it to work for my program. Here's what I have so far:
Code:
        NSMutableData *data = [[NSMutableData alloc] init];
	NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
	[archiver encodeObject:locations forKey:kDataKey];
	[archiver finishEncoding];
	
	NSString *post = [NSString stringWithFormat:@"data=%@", 					  
					  [self urlEncodeValue:data]
					  ];
	NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
	
	NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
	NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
	[request setURL:[NSURL URLWithString:@"http://localhost/uploader.php"]];
	[request setHTTPMethod:@"POST"];
	[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
	[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
	[request setHTTPBody:postData];
	
	// send it
	NSURLResponse* response;
	NSError* error;
	NSData *serverReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
It compiles and runs...doesn't work though. I also get a warning that urlEncodeValue might not exist or something.
jcafaro10 is offline   Reply With Quote
Old 05-19-2009, 12:31 AM   #31 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
funkytaco is on a distinguished road
Default

POSTing binary data is totally different than POSTing text.

Look here @ the uploadfile method and the one before it:
HTTP upload from native iPhone app
funkytaco is offline   Reply With Quote
Old 05-19-2009, 03:27 AM   #32 (permalink)
dot
Registered Member
 
Join Date: Feb 2009
Posts: 72
dot is on a distinguished road
Default

just subscribing to this thread
dot is offline   Reply With Quote
Old 05-19-2009, 05:39 AM   #33 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: India
Posts: 138
JohnMabassa is an unknown quantity at this point
Default

I am not sure whether this is what you are looking for. This has some info on uploading images.... I havent gone deeper into it
Upload Images

-John
JohnMabassa is offline   Reply With Quote
Old 05-19-2009, 11:35 AM   #34 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

It seems like the method specified in that post does several things that my php code isn't complex enough to handle.

Here's my php code:
Code:
<?php
$filename = 'test';
$content = $_GET["data"];

if (!$handle = fopen($filename, 'a')) 
{
	echo "Cannot open file ($filename)";
	exit;
}

if (fwrite($handle, $content) === FALSE) 
{
	echo "Cannot write to file ($filename)";
	exit;
}

echo "Success, wrote ($content) to file ($filename)";
fclose($handle);
?>
And here's my Objective C code:
Code:
- (NSData *)generatePostDataForData:(NSData *)uploadData
{
    // Generate the post header:
    NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\"; filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];
    
    // Get the post header int ASCII format:
    NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    
    // Generate the mutable data variable:
    NSMutableData *postData = [[NSMutableData alloc] initWithLength:[postHeaderData length] ];
    [postData setData:postHeaderData];
    
    // Add the image:
    [postData appendData: uploadData];
    
    // Add the closing boundry:
    [postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
    
    // Return the post data:
    return postData;
}

- (void)applicationWillTerminate:(UIApplication *)application
{
	NSMutableData *data = [[NSMutableData alloc] init];
	NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
	[archiver encodeObject:locations forKey:kDataKey];
	printf("Saving %d Locations",[locations count]);
	[archiver finishEncoding];
	
	// Generate the postdata:
    NSData *postData = [self generatePostDataForData: data];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
    // Setup the request:
    NSMutableURLRequest *uploadRequest = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://localhost/uploader.php"] cachePolicy: NSURLRequestReloadIgnoringLocalCacheData timeoutInterval: 30 ] autorelease];
    [uploadRequest setHTTPMethod:@"POST"];
    [uploadRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [uploadRequest setValue:@"multipart/form-data; boundary=AaB03x" forHTTPHeaderField:@"Content-Type"];
    [uploadRequest setHTTPBody:postData];
    
    // Execute the reqest:
    NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:uploadRequest delegate:self];
    if (conn)
    {
        // Connection succeeded (even if a 404 or other non-200 range was returned).
    }
    else
    {
        // Connection failed (cannot reach server).
    }
	
	//Local
	[data writeToFile:[self dataFilePath] atomically:YES];
	[archiver release];
	[data release];
}
How do I even know what type of file to save the data to? Also now I'm not posting text anymore, I'm posting a file. How does this work in php?

Last edited by jcafaro10; 05-19-2009 at 11:50 AM.
jcafaro10 is offline   Reply With Quote
Old 05-19-2009, 12:50 PM   #35 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
jsd is on a distinguished road
Default

You should head over to a php forum since all your questions now are PHP related.

I'll give you a hint though:
PHP: move_uploaded_file - Manual
jsd is offline   Reply With Quote
Old 05-19-2009, 02:37 PM   #36 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

I think I'm pretty close but still nothing happens. Here's my code, I've highlighted some sections where I think the problem might be:

Code:
- (NSData *)generatePostDataForData:(NSData *)uploadData
{
    // Generate the post header:
    NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\"; filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];
    
    // Get the post header int ASCII format:
    NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    
    // Generate the mutable data variable:
    NSMutableData *postData = [[NSMutableData alloc] initWithLength:[postHeaderData length] ];
    [postData setData:postHeaderData];
    
    // Add the image:
    [postData appendData: uploadData];
    
    // Add the closing boundry:
    [postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
    
    // Return the post data:
    return postData;
}

- (void)applicationWillTerminate:(UIApplication *)application
{
	//Both
	NSMutableData *data = [[NSMutableData alloc] init];
	NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
	[archiver encodeObject:locations forKey:kDataKey];
	printf("Saving %d Locations",[locations count]);
	[archiver finishEncoding];
	
	// Generate the postdata:
    NSData *postData = [self generatePostDataForData: data];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
    // Setup the request:
    NSMutableURLRequest *uploadRequest = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://192.168.1.100/uploader.php"] cachePolicy: NSURLRequestReloadIgnoringLocalCacheData timeoutInterval: 30 ] autorelease];
    [uploadRequest setHTTPMethod:@"POST"];
    [uploadRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [uploadRequest setValue:@"multipart/form-data; boundary=AaB03x" forHTTPHeaderField:@"Content-Type"];
    [uploadRequest setHTTPBody:postData];
    
    // Execute the reqest:
    NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:uploadRequest delegate:self];
    if (conn)
    {
        printf("success\n");
    }
    else
    {
        printf("fail\n");
    }
	
	//Local
	[data writeToFile:[self dataFilePath] atomically:YES];
	[archiver release];
	[data release];
}
PHP
Code:
<?php
$target_path = "uploads/";
$target_path = $target_path . basename($_FILES['somefile']['name']);
move_uploaded_file($_FILES['somefile']['tmp_name'],$target_path)
?>
Is there a way to see what is going on on the PHP end? I imagine I could print out some message to the gdb console using printf but I'm not sure what the php file would send back that I could print.
jcafaro10 is offline   Reply With Quote
Old 05-19-2009, 02:47 PM   #37 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
beachdog is on a distinguished road
Default

Quote:
Originally Posted by jcafaro10 View Post
Is there a way to see what is going on on the PHP end? I imagine I could print out some message to the gdb console using printf but I'm not sure what the php file would send back that I could print.
It might be easiest to just get a wireshark trace from either your client or server using tcpdump, so you can see exactly what you are sending over the wire, and whether the POST is as you expect
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 05-19-2009, 02:49 PM   #38 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

Quote:
Originally Posted by beachdog View Post
It might be easiest to just get a wireshark trace from either your client or server using tcpdump, so you can see exactly what you are sending over the wire, and whether the POST is as you expect
I'm not sure what that means. How do I do that? Do I write Objective-C code to show that?
jcafaro10 is offline   Reply With Quote
Old 05-19-2009, 03:05 PM   #39 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
beachdog is on a distinguished road
Default

Quote:
Originally Posted by jcafaro10 View Post
I'm not sure what that means. How do I do that? Do I write Objective-C code to show that?
I'm coming into this thread a bit late, so I apologize if I don't understand exactly where you are in the process.

If I understand, you have client (Obj-C) and server (php) code written and you are ready to test, but when you run the client nothing happens on the server, and now you want to troubleshoot that -- is that correct?

I guess the first thing is to be sure that your client is actually connecting to your server. To do that I would just step through your client code in the debugger. In the code you showed above you did not include the NSURLConnection delegate methods, but I assume you have implemented those. I would put breakpoints in those delegate methods and then run the client so I could be sure I was really connecting to the server and really sending data.

Next, if I wanted to see what the POST actually looked like going over the wire, then I would get a trace. To do that on my Mac OS I run the client in the simulator and then in a terminal window as a root user execute this command while the client is running:

#tcpdump -i en0 -s 0 -w test.cap

This generates a file that I can view in wireshark (open source download) and it will show all the packets entering and leaving my Mac (even if client and server are running on the Mac).
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 05-19-2009, 03:35 PM   #40 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

Can you please explain these delegate methods? I know that I need to use them for NSURLConnections but I'm not really sure I understand how. When I was just doing downloads, I had code that looked like this:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application 
{
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.100/uploads/blah.file"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
	NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
	if (theConnection) 
	{		
		receivedData=[[NSMutableData data] retain];
	} 
	else 
	{
		// inform the user that the download could not be made
	}	
[rootController setDelegate:self];
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{	
	[receivedData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
	[receivedData appendData:data];	
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
	[connection release];
	[receivedData release];
	NSLog(@"Connection failed! Error - %@ %@",
          [error localizedDescription],
          [[error userInfo] objectForKey:NSErrorFailingURLStringKey]);
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    // do something with the data
     [receivedData release];
    [connection release];
}
This is all fine and good, but now that I have uploading, I'll have two sets of delegate methods? Or can I just set some kind of boolean that specifies whether I'm uploading or downloading? I don't know what code I need to write in the delegate methods for uploading however. All of the delegate methods I have look like they are download specific.
jcafaro10 is offline   Reply With Quote
Old 05-19-2009, 06:01 PM   #41 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
beachdog is on a distinguished road
Default

Yes, those are the correct delegate methods. I have an example from an application of my own that does an upload of several items, including a file (a wave file in my case). In case it is helpful, here is the code:

Code:
-(void) callClicked:(id) sender {
	
	
	/* upload the greeting */
	NSString* boundary = [NSString stringWithString:@"0xMyLovelyBoundary"];
	NSData* data = [self createMultipartBodyWithBoundary:boundary];
	if( nil == data ) {
		//TODO: display error
		return;
	}

	NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/ACE/uploadConfOutdialGreetingRequest.jsp", [[GatherAppDelegate getAppDelegate] serverAddress] ]];
	NSLog(@"uploading file to url: %@", [url description] ) ;
	NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];
	[request setHTTPMethod:@"POST"];
	[request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forHTTPHeaderField:@"Content-Type"];
	[request setValue:[NSString stringWithFormat:@"%d", [data length]]  forHTTPHeaderField:@"Content-Length"];
	[request setHTTPBody:data];
	NSURLConnection* connection = [NSURLConnection connectionWithRequest:request delegate:self];
	
	if( nil == connection ) {
		[[[UIAlertView alloc] initWithTitle:nil 
				message:NSLocalizedString(@"connection_failed","") delegate:self cancelButtonTitle:NSLocalizedString(@"ok","") otherButtonTitles:nil] show];
		return ;
		
	}
}

#pragma mark BEGIN helper functions to manage upload of recording
-(NSData*) createMultipartBodyWithBoundary:(NSString*) boundary {
	
	GatherAppDelegate* d = [GatherAppDelegate getAppDelegate];	
	NSFileManager* fileManager = [NSFileManager defaultManager];
	
	NSString *recordingFilename = [NSString stringWithFormat: @"%@/Recording.wav", d.recordingDirectory];
	NSUInteger initSize = 0;
	NSDictionary* dict = [fileManager fileAttributesAtPath:recordingFilename traverseLink:NO];
	if( nil != dict ) {
		initSize = (NSUInteger) [dict objectForKey:NSFileSize];
	}
			
	
	/* write subscriberid and confschedid*/
	Conference* conf = [d.arrConferences objectAtIndex:0];
	NSString* strSubId = d.mod.subscriberId ;
	NSString* strConfId = conf.conferenceId ;
	
	NSMutableData* data = [NSMutableData data];
	[data appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"subscriberid\"\r\n\r\n%@",strSubId] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"confschedid\"\r\n\r\n%@",strConfId] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"uploadFile\"; filename=\"recording.wav\"\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"Content-Type: audio/wav\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
	[data appendData:[[NSString stringWithFormat:@"Content-Transfer-Encoding: binary\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];

	/* now append the contents of the recording file */
	[data appendData:[fileManager contentsAtPath:recordingFilename]];
	[data appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]];

	return data;
}

#pragma mark NSURLConnection delegate methods
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse {
	return request;
}
- (void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
	return ;
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
	NSLog(@"file upload failed with error: %@", [error localizedDescription] );
	[self finishUpload:NO];
	
	return ;
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
	return ;
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
	
	NSString* strData = [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSASCIIStringEncoding] autorelease];
	NSLog(@"Received data: %@", strData ) ;
	return ;
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
	return ;
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse {
	return cachedResponse;
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
	NSLog(@"file upload completed with HTTP success");
	[self finishUpload:YES];
	return;
}
#pragma mark end of NSURLConnection delegate methods
__________________
My Apps - Carbfinder, My BG Lite
beachdog is offline   Reply With Quote
Old 05-20-2009, 11:47 AM   #42 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

I included all of those delegate methods and put a breakpoint next to each one and none of them get called
jcafaro10 is offline   Reply With Quote
Old 05-20-2009, 11:54 AM   #43 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 36
beachdog is on a distinguished road
Default

Quote:
Originally Posted by jcafaro10 View Post
I included all of those delegate methods and put a breakpoint next to each one and none of them get called
When you show your code above, you had this being done in the applicationWillTerminate method. Is there any reason for that? For now, for test purposes I would suggest just hooking it up to a button you can push or something. I'm not sure whether a connection request made as the application is terminating will be allowed to go through.

Also, keep in mind these delegate methods are going to be called asynchronously, so when your code returns from instantiating the NSURLConnection object you should not assume the connection has completed.

Other than that, those delegate methods should get called as long as you set up the connection correctly. I'd look carefully at any differences between the code I showed and yours, as mine works as expected.
__________________
My Apps - Carbfinder, My BG Lite

Last edited by beachdog; 05-20-2009 at 11:56 AM.
beachdog is offline   Reply With Quote
Old 05-20-2009, 11:55 AM   #44 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
jsd is on a distinguished road
Default

You might want to try using this package for posting files and data, it's way easier than rolling your own:

ASIHTTPRequest Documentation - All-Seeing Interactive
jsd is offline   Reply With Quote
Old 05-20-2009, 12:27 PM   #45 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 88
jcafaro10 is on a distinguished road
Default

I had it on application will terminate so that I could have it upload the results when I'm done. I can try it with a button too. I'll also try to figure out the ASIHTTPRequest stuff as well.
jcafaro10 is offline   Reply With Quote
Old 09-04-2009, 01:51 AM   #46 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 5
guptatarun84 is on a distinguished road
Default

hi,

I am able to record the voice in .caf format. But the problem here is i have to upload the Recording.caf file to server which do not convert .caf to .mp3. So i have to change the format of recording from .caf to .mp3 or .wav.

Please flash some idea of how to do it?

Thanks,
guptatarun84 is offline   Reply With Quote
Old 09-07-2009, 08:39 AM   #47 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
funkytaco is on a distinguished road
Default

guptatarun84, please start a new thread. Your problem is unrelated to this one.
funkytaco is offline   Reply With Quote
Old 09-10-2009, 12:16 PM   #48 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 9
funnylookinhat is on a distinguished road
Default Status of POST upload...

I'm doing nearly the same thing as you, sending POST data via a sendSynchronousRequest - and I do it in the background with :

[self performSelectorInBackground:@selector(pleaseUpload File) withObject:nil];

This works great - and for now I just set a UIActivityIndicator to animate while the file is uploading so that the user doesn't think everything just stopped working...

However, I noticed that the upload to youtube feature on the new iPhone 3GS allows the tracking of the upload by using a progress bar...

How would I check how much of the post data has been sent so far so that I can update the value on that progress bar accordingly?
funnylookinhat is offline   Reply With Quote
Old 07-19-2010, 02:05 AM   #49 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 8
ravindra1989 is on a distinguished road
Default How to upload and access recorded voice through iphone to webserver

i am new to iphone apps developement...
My apps record a voice through iphone. But i want that to upload to web server and able to access that... can any one help me?????
ravindra1989 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
5 members and 322 guests
blueorb, guusleijsten, Kryckter, LEARN2MAKE, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:54 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0