Upload Files

new BookmarkLockedFalling
kokenge
Senior Member
****

kokenge Avatar

Posts: 261

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.


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

Last Edit: Dec 10, 2010 20:57:44 GMT -5 by kokenge
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM