UPLOAD not working from from app in run command

new BookmarkLockedFalling
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
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
meerkat
Senior Member
****

meerkat Avatar

Posts: 250

Post by meerkat on Sept 9, 2012 10:14:04 GMT -5

Since the Upload does not work in the program that was run, the trick is to run the code in the main program.
You can pass data in the UserInfo$.
You can hide a button in the main program that you do not see, but the RUNNED programs can get to it. This makes it possible to run code in the main RUNNITG program. You basically click a hidden, or visible if you like, [button] in the main program from your RUNNED program.
Plus you only have one set of code to do uploads in all your RUNNED programs.
I also use this method for code that is repeated in many RUNNED programs so I only have one set of code for the system.

It works for me.
Something similar to this should work:


'====================================
'in the main program

CSSClass ".hide", "{visibility: hidden; height:0px; bprder:none}"

button #upload, "Upload" ,[doUpload]
#upload cssclass("hide")
#upload setid("upload")

incdir$ = DefaultDir$ + "\projects\your_project\"
prog$ = "yourProgram.bas
run incdir$;prog,ドル#include
render #include

wait

' -----------------------------------------
' Do Upload
' -----------------------------------------
[doUpload]
uploadId$ = word$(UserInfo,1,ドル"|")
photoWide$ = word$(UserInfo,2,ドル"|")
photoHigh$ = word$(UserInfo,2,ドル"|")
photoWide = val(photoWide$)
photoHigh = val(photoHigh$)

upload ""; uploadId$

f$ = photoDir$;uploadId$
files #f, f$
if #f HASANSWER() then
errNum = errNum + 1
errMsg$(errNum) = "Photo: ";uploadId$;" is already in photo directory"
gosub [doMsg]
wait
end if

' -------------------------------------
' load photo to photo directory
' -------------------------------------
OPEN uploadId$ FOR binary AS #f
filedata$ = input$(#f, LOF(#f))
CLOSE #f

OPEN f$ FOR binary AS #f
PRINT #f, filedata$
CLOSE #f

loadgraphic #g, f$
photoHigh = #g height()
photoWide = #g width()
photoHigh$ = str$(photoHigh)
photoWide$ = str$(photoWide)
#g discard()

photoId$ = uploadId$

w = (photoWide / photoHigh) * 200
' This puts the photoId, width etc back into <input values in the RUNNED program
html "<script> document.getElementById('photoId').value = '";photoId$;"';</script>"
html "<script> document.getElementById('photoWide').value = '";photoWide$;"';</script>"
html "<script> document.getElementById('photoHigh').value = '";photoHigh$;"';</script>"
html "<script> document.getElementById('photo').innerHTML = '"
html "<IMG SRC=";photoPath$;photoId$;" width=";w;">"
html "';</script>"
wait


'=================================
' in the runned program

button #upld, "Upload Maintenance",[doUpload]
#upld setid("upldMe")
html "<script>document.getElementById('upldMe').name = document.getElementById('upload').name;</script>"
Last Edit: Sept 9, 2012 11:07:33 GMT -5 by meerkat