Shortly after my last post I actually had a pretty major breakthrough with the upload proof of concept. I managed to get my Android application (running on the emulator) to upload a file to a server on my local machine. The PHP approach to the problem ended up being the way to go. I added a post to this thread which had been confusing me for about a week. Tons of people posted saying “it worked” or “this is the client side code that worked”, but nobody simultaneously posted the PHP and Client-side snippets which worked for them.
I found the XAMPP server application very helpful as I worked on doing the initial proof of concept. It creates a server on the localhost of your machine, so you can test web code without actually deploying it on a server (which is a whole other set of headaches-the ones I currently have!). One little gotcha that Carny helped me fix is that the permissions on the directory you want to upload to – they need to be such that your ‘server user’ has permissions to write to that directory (or just chmod 777 but be aware that this is NOT the good/secure way to do it – it works if you just need to test it and set it back afterwards though).
Another interesting thing I learned today was how to add a faux-SDCard to your android emulator. Just run the commands on that site in a terminal (from your tools directory). In order for the file upload to work, you need to manually push the file to your Android’s SD Card!
Also, please note (and I’ve forgotten it twice already since learning it in that tutorial…) that the directory path given in that link is NOT what you want to put as your own eclipse path. It looks deceptively like some super-secret google pathname, a G: drive, Android, SDK_Root, etc. However, this is just the path that the creator of the tutorial happened to have on his PC. You need to insert the path to the sdcard you create!
My next task will be to get the file upload working from a real Android phone to an actual server. I’ve been working on getting the uploader.php to run on Octopussy, but so far I’m getting errors. The PHP that I set up seems to be working fine though, which is nice to see. Hopefully by tomorrow I’ll have it all up and running!