APIs: Save the contents of a TextBox, Label, variable, etc. to the SDCARD

1,103 views
Skip to first unread message

Scott Ferguson

unread,
Sep 30, 2012, 11:07:05 AM9/30/12
to app-inventor-de...@googlegroups.com

This uses the Web component to send the contents of a block in App Inventor to a php server where it is echoed back to a GotFile block and saved in a designated file on the sdcard.
This would allow saving data from TinyDB also on the sdcard.

The php script to echo the text to a file: <?PHP echo file_get_contents('php://input'); ?>
text_2_sdcard.zip

David Sanborn

unread,
Jan 10, 2013, 7:52:22 PM1/10/13
to app-inventor-de...@googlegroups.com
I'm not fimiliar with php. How do I use this. Make an html file with it?

Scott Ferguson

unread,
Jan 12, 2013, 1:56:34 PM1/12/13
to app-inventor-de...@googlegroups.com
You can get free web hosting at sites like 000webhost.com. Then post a php file containing the above code. and access it with AI's web component.
No html is involved.
---sfs

David Sanborn

unread,
Jan 12, 2013, 5:51:24 PM1/12/13
to app-inventor-de...@googlegroups.com
Thanks for sharing that. So I just drop the PHP code into the editor of say a subpage and when that page is called on, it processes it?

Scott Ferguson

unread,
Jan 13, 2013, 11:42:09 AM1/13/13
to app-inventor-de...@googlegroups.com
That's all there is to it!
---sfs

Taifun

unread,
Feb 28, 2013, 6:42:22 PM2/28/13
to app-inventor-de...@googlegroups.com
I now adjusted your example for server which do not offer to set always_populate_raw_post_data to on
you can find this workaround here: http://puravidaapps.com/save.php
Taifun

Scott Ferguson

unread,
Feb 28, 2013, 6:50:54 PM2/28/13
to app-inventor-de...@googlegroups.com
Thanks for the link and providing a solution, Taifun. I like the idea of having a password for security purposes also.
---sfs

Ivan Damyanov

unread,
Mar 11, 2013, 2:01:35 PM3/11/13
to app-inventor-de...@googlegroups.com
How can we avoid overwriting a file? If a file with name hello.txt exists, create hello2.txt , is that possible?
Also, after saving to a file on SD , after my text there always is some kind of comment with a link and more stuff, this must be coming from the host im using right? (000webhost)

Scott Ferguson

unread,
Mar 14, 2013, 8:31:30 AM3/14/13
to app-inventor-de...@googlegroups.com
1. I cannot think of a way to 'sense' if a file exists as the process now is 'dumb'. There may be a way to do a read test with javascript first before doing the download. Taifun might have a suggestion there.
2. yes. I need to turn that off. Thanks for the heads up.
---sfs
Message has been deleted
Message has been deleted

Dread 88 Seller

unread,
Aug 20, 2013, 4:03:25 AM8/20/13
to app-inventor-de...@googlegroups.com
Hi!
Thank You for your reply!
I got a little help and the problem solved, the problem was that I didnt copy PHP Compat folder to my server.
But noew it works fine!
Thank You for the script!

Regards,
Tamas


2013/8/18 Taifun <taifu...@gmail.com>
is that your server?
can't you set the flag always_populate_raw_post_data to on on your server?
did you follow these instructions http://puravidaapps.com/save.php to install the PEAR::PHP_Compat package ?
Taifun

--
(you have received this message from the App Inventor Developers Library)
---
You received this message because you are subscribed to the Google Groups "App Inventor Developers Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to app-inventor-develope...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

fishingjr

unread,
Dec 3, 2013, 10:57:20 PM12/3/13
to

On Saturday, January 12, 2013 12:56:34 PM UTC-6, Scott Ferguson wrote:
You can get free web hosting at sites like 000webhost.com. Then post a php file containing the above code. and access it with AI's web component.
No html is involved.
---sfs

The php script to echo the text to a file: <?PHP echo file_get_contents('php://input'); ?>
 
 
========
 
Scott,  I have been using the both get_url.php  and openlocalfile.php for over a year now .  Everything has been working great! 
 
Today, 000webhost had a sever problem and had a statement on the server that they would be back up in 2-3 hours.  During that time I was not able to see my website at all.  Now the server is back online and I am able to see my website.  Also, both of the PHP files are there.  However my PHP files no longer return the html that I send.  Can you check and see if yours still work on 000webhost?  I have a service ticket open at 000webhost but have not received a reply yet.  I am on server #44 if it matters... 
 
I am also wondering if the file access rights might have changed. The original server error message was that a disk drive was reporting a 'read only file system' error.  I can't remember if I need to change the permissions for read write on the PHP files.
 
 
When I send HTML from my AppInventor app, this is what I get in return:

<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
 
 
Thanks for all your help!!!!

Scott Ferguson

unread,
Dec 4, 2013, 12:32:56 AM12/4/13
to app-inventor-de...@googlegroups.com
Here is a link to turn off the analytics code: http://members.000webhost.com/analytics.php
Then try again.
---
Scott


On Tuesday, December 3, 2013 9:33:31 PM UTC-6, fishingjr wrote:

On Saturday, January 12, 2013 12:56:34 PM UTC-6, Scott Ferguson wrote:
You can get free web hosting at sites like 000webhost.com. Then post a php file containing the above code. and access it with AI's web component.
No html is involved.
---sfs

The php script to echo the text to a file: <?PHP echo file_get_contents('php://input'); ?>

fishingjr

unread,
Dec 4, 2013, 2:22:57 AM12/4/13
to app-inventor-de...@googlegroups.com
Thanks,  I turned off the analytics code and now I get nothing in the response.

Scott Ferguson

unread,
Dec 4, 2013, 6:41:07 AM12/4/13
to app-inventor-de...@googlegroups.com
This is what I get:

BTW you are welcome to use my server for testing.

I used: http://www.aiapis.org/php/openlocalfile.php in this example. My server has changed and all php files are in the php folder.

---

Scott

Scott Ferguson

unread,
Dec 4, 2013, 6:50:09 AM12/4/13
to app-inventor-de...@googlegroups.com

Scott Ferguson

unread,
Dec 4, 2013, 6:52:02 AM12/4/13
to app-inventor-de...@googlegroups.com
I cannot get to my server at all. aiapis.org is down. :(
---
Scott

fishingjr

unread,
Dec 5, 2013, 11:41:34 AM12/5/13
to
Scott, thanks again for your help.  I did use your server and everything worked, so I knew it was a server issue... That helped a lot!!!!
 
Ended up finding out the permissions did get changed.
 
>>> permissions: all php files should be chmod 644 (and if they are within a folder, the folder should be chmod 755)
 
Once I changed the permissions back, everything is working great again!!!
 
I also got tired of Free server tech support and purchased a domain and hosting service.  I think I'm going to like!!!
 
(I understand I wasn't paying anything, what tech support should I expect.  But, everything was working great until they had a drive crash and changed everything to read only.)
 

Scott Ferguson

unread,
Dec 5, 2013, 11:01:00 AM12/5/13
to app-inventor-de...@googlegroups.com
Thanks for the chmod 644 tip. That may help someone in the future. hAPPy INVENTORing!
---
Scott


On Thursday, December 5, 2013 9:48:38 AM UTC-6, fishingjr wrote:
Scott, thanks again for your help.  I did use your server and everything worked, so I knew it was a server issue... That helped a lot!!!!
 
Ended up finding out the permissions did get changed.
 
>>> permissions: all php files should be chmod 644 (and if they are within a folder, the folder should be chmod 755)
 
Once I changed the permissions back, everything is working great again!!!
 
I also got tired of Free server tech support and purchased a domain and hosting service.  I think I'm going to like!!!
 
(I understand I was paying anything, what tech support should I expect.  But, everything was working great until they had a drive crash and change everything to read only.)
 
Reply all
Reply to author
Forward
0 new messages