UPLOAD data
Nov 18, 2019 9:11:59 GMT -5
Post by meerkat on Nov 18, 2019 9:11:59 GMT -5
We all know the UPLOAD command does not run in programs that were run from another program.
The upload command is the html "<input type='file' id='f' name='f' >" command. However trying that html command with the Run Basic command file$ = #request get$("f") does not work. It takes a special request that RB dose not support. So how do you get the file from the <input type='file' to run basic. There is a way but requires some javaScript. A better way is to do a shell to the directory. I'll show both here.
========================================================
UPLOAD. Biggest problem with UPLOAD is that it was designed for the web and does not supply you with the associated directory. When the <input type='file' is changed it sends the information to the javaScript rbMsg(x) in x. rbMsg sends the x value to the hidden <input text named rbPass and clicks the RB button named rbLink. Sinse rbLink is a Run Basic command it tells RB to request the data from the rbPass. Kinda tricky, but it works.
====================================================================
DIR.
This simply Shells out a dir command. It returns the file you select in name$. You can set dirOf$ to any directory you want to start from..
You can also change the Shelled DIR command with different options such as /A /S etc.
Hope this helps..
The upload command is the html "<input type='file' id='f' name='f' >" command. However trying that html command with the Run Basic command file$ = #request get$("f") does not work. It takes a special request that RB dose not support. So how do you get the file from the <input type='file' to run basic. There is a way but requires some javaScript. A better way is to do a shell to the directory. I'll show both here.
========================================================
UPLOAD. Biggest problem with UPLOAD is that it was designed for the web and does not supply you with the associated directory. When the <input type='file' is changed it sends the information to the javaScript rbMsg(x) in x. rbMsg sends the x value to the hidden <input text named rbPass and clicks the RB button named rbLink. Sinse rbLink is a Run Basic command it tells RB to request the data from the rbPass. Kinda tricky, but it works.
' --------------------------------------
' read PDF cnverted file
' --------------------------------------
CSSClass ".hide", "{visibility: hidden; height:0px; bprder:none}"
html "<script>
function rbMsg(x) {
document.getElementById('rbPass').value=x;
document.getElementById('rbLink').click();
}
</script>"
html "<input type='hidden' value='nothing' name='rbPass' id='rbPass'>" ' where the pass data is placed for RB
button #rbLink,"rbLink",[rbGo] ' the hidden RB button
#rbLink setid("rbLink")
#rbLink cssclass("hide")
html "<input type='file' id='f' name='f' accept='c:\rbp101\*.txt' onChange=rbMsg(document.getElementById('f').value)>"
wait
[rbGo]
cls
f$ = #request get$("rbPass") ' get the pass data and determine what routine
f$ = pdfDir$ + word$(f,2,ドル"path\")
====================================================================
DIR.
This simply Shells out a dir command. It returns the file you select in name$. You can set dirOf$ to any directory you want to start from..
You can also change the Shelled DIR command with different options such as /A /S etc.
' ---------------------------------------------
' Directory
' ---------------------------------------------
cr$ = chr$(13)
dirOf$ = "c:\" ' get directory of
bf$ = "<SPAN STYLE='font-family:Courier New; font-weight:700; font-size:10pt'>"
' -------------------------------------------
' Shell out directory
' -------------------------------------------
[dirShell]
cls
html bf$
loc$ = strRep$(dirOf,ドル"*.*","")
x$ = shell$("dir ";dirOf$)
i = 1
while word$(x,ドルi,cr$) <> ""
a$ = word$(x,ドルi,cr$)
if trim$(a$) = "" then goto [next]
if left$(a,1ドル) = " " then goto [next]
if left$(a,1ドル) = cr$ then goto [next]
type$ = mid$(a,26,3ドル)
size$ = mid$(a,30,9ドル)
size$ = strRep$(size,ドル",","")
size = val(size$)
if type$ <> "DIR" and size = 0 then goto [next]
name$ = mid$(a,40ドル)
a$ = strRep$(a,ドル"<","[")
a$ = strRep$(a,ドル">","]")
html left$(a,39ドル)
link #ddir,name,ドル [doDir]
#ddir setkey(type$;"|";loc$;"\";name$)
html "<BR>"
goto [next1]
[next]
print a$
[next1]
i = i + 1
wend
wait
[doDir]
type$ = word$(EventKey,1,ドル"|")
name$ = word$(EventKey,2,ドル"|")
if type$ = "DIR" then
dirOf$ = name$;"\*.*"
goto [dirShell]
end if
print "Selected File:";name$
wait
' --------------------------------
' string replace rep str with
' --------------------------------
FUNCTION strRep$(str,ドルrep,ドルwith$)
ln = len(rep$)
ln1 = ln - 1
i = 1
while i <= len(str$)
if mid$(str,ドルi,ln) = rep$ then
strRep$ = strRep$ + with$
i = i + ln1
else
strRep$ = strRep$ + mid$(str,ドルi,1)
end if
i = i + 1
WEND
END FUNCTION
Hope this helps..