LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NXG : How to read/upload a file in a webVI ?

Solved!
Go to solution

Hi

I am new, like most of us, to Labview NXG and I have a simple question : I want to make a webpage with some simple calculations. I need that the user provides his own data in a simple ASCII file that can be uploaded from his computer. How to do that in WebVi ? I don't see any "file management" vi 

Thanks

0 Kudos
Message 1 of 20
(7,201 Views)

Hi nitad54448,

 

There is no "file management" VI for now but you can change the HTML code of your WebVI to do that.

Try to include this code :

 

https://stackoverflow.com/a/29176118

And don't forget to build the application to have the .html which corresponds to your WebVI.

 

Have a nice day.

Message 2 of 20
(7,130 Views)

Hi

Thanks for the answer.

OK, I understood from the NXG presentations that we don't need a web programmer anymore. Is there any plan to add "file management" ? Otherwise, for reading google maps and this type of software that is presented with Nxg, I can use wordpress (easier... and much cheaper )

N

0 Kudos
Message 3 of 20
(7,110 Views)

Can you elaborate more?

 

What is in the text file you want to upload (small file with configuration constants?  large data file?) and

What you want to do in the WebVI if you could upload it (data visualization? filter data?) and

Do you also need the ability to generate and download a results file?

Darin Gillis
NI - Chief Product Owner - VeriStand
0 Kudos
Message 4 of 20
(7,088 Views)

Hi

Yes, something like that. I want to read  an ASCII file with some XY data, then smooth, show,.. calculate (like fitting...) then save the results (or at least print it on the screen). The file format might change from time to time so adding html code for each case it's impossible.

N

Message 5 of 20
(7,086 Views)

Hi

The latest NXG allows ASCII file reading/upload on web ?

thanks

0 Kudos
Message 6 of 20
(6,794 Views)

Hi nitad54448,

 

It isn't built in functionality but I have an example that allows you upload a text file into a WebVI and returns the document as a string by using a JavaScript Library Interface (JSLI) document. I will post it. What version of LabVIEW NXG are you using?

 

Also, I don't know if you saw the WebVI GitHub example but it is a good source for ideas:

https://github.com/ni/webvi-examples

 

Thanks,

Frank

0 Kudos
Message 7 of 20
(6,773 Views)

Hi nitad54448,

 

Please see the attached example project. It is saved in LabVIEW NXG 3.1.1, and uses the NXG Web Module.

 

I created this example by doing these steps:  

1. Open HTML Editor and add an input button and make invisible in the <div class="ni-front-panel-wrapper"...  </div>
<input type="file" id="myFile" style="display: none;">
2. Add JSLI node in its own Library component. Add the functions in the OpenFileWebVI.js to the JSLI node.

3. Add button to call OpenFileWebVI from JSLI, wait for file read to complete, and write text to String indicator.

 

A couple other notes:

  • If want to use this in another project, you can copy the UploadLibrary.gcomp and the HTML input element in the NXG HTML Editor (step 1).
  • This example works in Chrome and Opera (doesn't currently work in Edge or IE)

  • The dialog box will only appear when run in the browser. This is a known issue as NXG doesn't currently support the browser dialog functionality. 

 

Upload a File.pngUpload a File Web.png

Please let me know if you have questions. 

 

Thanks,

Frank

Message 8 of 20
(6,740 Views)

Thanks for your help Frank is a very god job!

I using your library and it works as expected.

Do you maybe have a similar library for write/download file?

 

Thanks in advance

Tiziana

0 Kudos
Message 9 of 20
(6,714 Views)
Solution
Accepted by topic author nitad54448

Hi pirulla72,

 

Thanks! Great, I am happy to hear that it worked.

 

I don't have an example for write/download a file but I will try to work one in the next few days. If you are feeling motivated to try and add this functionality with the JSLI, these two links seem helpful:

 

How to create a file in memory for user to download, but not through server?

https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-...

http://jsfiddle.net/VBJ9h/319/

 

Thanks,

Frank

Message 10 of 20
(6,667 Views)