Upload Files
Dec 10, 2010 20:57:05 GMT -5
Post by kokenge on Dec 10, 2010 20:57:05 GMT -5
This routine will allow you to upload files from the client.
I've tested it in Chrome and FireFox.
You choose a file, load it, make any changes, and send it.
I've tested it in Chrome and FireFox.
You choose a file, load it, make any changes, and send it.
html "
<script type='text/javascript'>
function load() {
var finput = document.getElementById('data');
var editor = document.getElementById('editor');
var f = finput.files[0];
if (f) {
var r = new FileReader();
r.onload = function(e) { editor.innerHTML = e.target.result }
r.readAsText(f);
} else {
editor.innerHTML = 'Failed to load file' }
}
function format(c) { document.execCommand(c, false, false); }
</script>
"
bf$ = "<SPAN STYLE='font-family:Arial; font-weight:700; font-size:10pt'>"
html bf$;"<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 bgcolor=wheat>"
html "<TR><TD COLSPAN=4 ALIGN=CENTER>File Upload</TD></TR>"
html "<TR align=center><TD>"
html "<input type='file' id='data' />"
html "</TD><TD>"
html "<input type=button onClick='load()' value='Load'></input>"
html "</TD><TD>"
button #snd, "Send", [doSend]
html "</TD><TD>"
button #ex, "Exit", [doExit]
html "</TD></TR><TR><TD COLSPAN=4>"
textarea #ed,loadData,80,15ドル
#ed setid("editor")
html "</TD></TR></TABLE>"
wait
[doSend]
print "Do our send code here"
wait
[doExit]
print "Do your exit here"
wait