Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Simple Writing to Text File Web Server - iPhone SDK
I have a website server and I am trying to get it to communicate with my app. I am able to 'download' from the server to read text files and use them as NSStrings, but I was wondering how I could go the other way around. I am trying to 'upload' a short NSString to my server by either:
-Adding a line to an existing text file
-Creating a whole new text document and uploading that
I am guessing I need will need somehow need to use the FTP login details, but otherwise I am lost as to how to start.
Any help would be much appreciated.
0 •
Replies
I am assuming it is and if that is the case you can write a simple php file that will take in a url parameter to write to your server.
You could write a php file called say... writetext.php Then from within your app you could do something like this: You would probably want to use a library like ASIHTTPRequest or since that library is not being supported any longer this one is probably better https://github.com/gowalla/AFNetworking.
You also may notice that in our examples we are using synchronous requests, but this is really only for simplifying our example code for demonstration purposes. In general, you should really use asynchronous requests because synchronous requests will lock up your user interface for the duration of the request.
Of course you could always use a service like www.parse.com for cloud storage API too
Let me know if you have any questions
iPhone App Templates
app templates
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeMy php file is identical to yours.
And this is my current Xcode action:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeEdit: It keeps messing up my " by replacing it with "e; Also make sure you add the php tags into your php file, since I forgot to put them in in my original post (I have edited it now to below like it should be)
iPhone App Templates
app templates
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeXcode:
Php File:
However, nothing happens when I call the xcode action, but when I load the url of where the writetext.php file is located, then it creates the testFile.txt and has the text "my posted var."
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeLet me know if this works for you
iPhone App Templates
app templates
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeDownloading file:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf you hunt around on the internet you should be able to find a tutorial on using an NSURLRequest to do an HTTP put.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeiPhone App Templates
app templates
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeiPhone App Templates
app templates
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeiPhone App Templates
app templates
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome