Now I want to read some files in the user’s computer, var filename should be replaced by the user’s local file, What should I do if I want to add this to my own index.html? Thanks.
Appreciate for your reply. Actually, I want to realize a event display app on my http server with JSROOT API, the user could specify a root file on their own computers (not on the server) and my app would read this root file. The files are very large, so it’s not a good idea to upload the entire file to the server. I found that the GUI of JSROOT project provides the “select local file for reading” button, how can I add this button in my custom HTML? Use HTML5 FileReader or something else? Thanks!
Either use local http server, which will serve your ROOT files. It could be Apache or civetweb or any other web server.
Try to use HTML5 FileReader. For that you need to create special HTML element with file selection. Like described here - https://www.html5rocks.com/en/tutorials/file/dndfiles/ FileReader object can be provided directly as argument of JSROOT.OpenFile() function.
var file_reader = evt.target.files[0]; // see example
JSROOT.OpenFile(file_reader, function(file) {
file.ReadObject(“hpxpy;1”, function(obj) {
JSROOT.draw(“drawing”, obj, “colz”);
});
});