One of the crucial requirements in the application I am writing is that user being able to upload (input type="file") a photo from within a form.
Does the android web browser support File Uploads? If yes do all versions 1.5+ support it?
One of the crucial requirements in the application I am writing is that user being able to upload (input type="file") a photo from within a form.
Does the android web browser support File Uploads? If yes do all versions 1.5+ support it?
I wanted an easier way to get files off my phone rather than pulling out the SD card and I thought to just have a CGI program receive them on a web server so I had the same question. I wrote a small script that can successfully upload files from remote computers using a web browser. It looks like this:
#!/usr/bin/python
import os
import cgi
def tag(tag, contents=None, attlist=None):
tagstring= "<"+tag
if attlist:
for A in attlist:
V= attlist[A].replace('"','"')
attstring= ' '+A+'="'+V+'"'
tagstring += attstring
if contents:
tagstring += ">\n"+contents.rstrip()+"\n</"+tag+">\n"
else:
tagstring += "/>\n"
return tagstring
content_type= 'Content-type: text/html\n\n'
form = cgi.FieldStorage()
if not form:
acturl= "./up.py"
ff= tag('input','',{'type':'file','name':'filename'}) + tag('input',''{'type':'submit'})
f= tag('form',ff, {'action':acturl, 'method':'POST', 'enctype':'multipart/form-data'})
H= tag('head', tag('title', "Uploader"))
B= tag('body', tag('p', f))
print content_type + tag('html', H + B)
elif form.has_key("filename"):
item = form["filename"]
if item.file:
data = item.file.read()
t= os.path.basename(item.filename)
FILE= open("/home/user/public_html/uploads/"+t,'w')
FILE.write(data)
FILE.close
msg= "Success! "
else:
msg= "Fail. "
H= tag('head', tag('title', "Uploader"))
B= tag('body', tag('p', msg + tag('a','Another?',{'href':'./up.py'})))
print content_type + tag('html', H + B)
Running a test with a program like this is the only sure way to know if your brand of phone browser does what you want, but for me: it worked. I was even able to use Apache mod_auth to require a username and password and the Android browser politely let me input that. Then when I selected the choose file button, it brought up a menu offering to let me choose from the Gallery, music ap, sound recorder, and a file manager ap I installed. I picked a file from the gallery and, although it took its sweet time, it uploaded fine. So the answer to the question for me was "yes". And for you - try out a test program like the one posted.