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?
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
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.
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.
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
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.
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
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.
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:
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.
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
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?
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).
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.
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:
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.
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.
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.
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?
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?????