I discovered that this code will load a text file:
st := TStringList.Create;
st.LoadFromFile ('http://localhost:8000/drawNetwork/model.json');
showmessage (st.Text);
but I've no idea how to load a file from a different location. All saves that a user does go to the Downloads directory so I would like to be able to upload the files from there but using a TWebButton. I can load files using TWebFilePicker and TWebFileUpoad but I can't use these componentsbecause I can't style them to fit into the rest of the UI look and feel.
Any suggestions?
You will understand that you cannot use another way to access local files than going via the file picker / file upload. You can't just execute code that would load just any local file without user interaction. That would imply a HUGE security hole in the browser where any web application could just access (steal?) local files from users.
You can use CSS if you want to further customize the look & feel of either TWebFilePicker or TWebFileUpload.
Thanks for the reply. I think I see what you're saying, TWebFlePicker lets me load a file from anywhere on the local drive but only as a result of a user interaction. I noticed that in the regular expression demo that files are read using TStringlist.loadfromfile. I assume this is ok because the method loadFile is called from within the TWebCombo OnChange event? Presumably calling loadFile outside this context wouldn't work.
I'll see what I can do with css on the web picker. I've tried boostrap but that didn't work well on the webpicker, the text rendering and background color is unaffected.
I figured it out, it took a bit of effort. The problem is the picker component itself can't be visually customized easily. Instead I overlay a TWebButton on top of the picker all inside a TWebHTMLDiv container. The last thing to do is make sure the button click event falls through to the picker underneath. The only thing I havn't implemented is a hover feature but that shouldn't be too dififcult.
If anyone wants the CSS let me know.