1

I am newbie to AngularJS. Currently I am trying to implement file reading through AngularJS. I can upload .txt file and show the data in content which is working fine.

Example

Demo Link

How can I open notepad.exe and show content by Using AngularJS ?

Can anyone help me on this?

Nishat Lakhani
  • 733
  • 1
  • 8
  • 20
Suresh B
  • 1,658
  • 1
  • 17
  • 35
  • see this link [http://stackoverflow.com/questions/18980957/is-it-possible-to-run-an-exe-or-bat-file-on-onclick-in-html](http://stackoverflow.com/questions/18980957/is-it-possible-to-run-an-exe-or-bat-file-on-onclick-in-html) – Carlos Galan Mar 04 '16 at 06:34
  • Open notepad.exe? What for? To show content? Why not show it on the page itself? – Sergio Tulentsev Mar 04 '16 at 06:34
  • No, In my application Uploaded file content be more and I need to open more than one file. do some compare. – Suresh B Mar 04 '16 at 06:38

1 Answers1

0

Yes, web pages can read files from the file system in a very restricted way: there must be an <input type="file"> on the page, the user must activate it, and they must select file(s) in some platform specific manner. These restrictions exist for obvious security reasons. A page cannot arbitrarily read a file given a path.

Once the user has selected one or more files, you can read the files property from the input element, and get an array of File objects. Instantiate a FileReader object with the File, and use one of the methods there to read the file, such as readAsBinaryString().

MDN has a pretty good overview of accessing files from web applications. It goes into more detail about handling things like drag and drop.

If you are using this in an AngularJS application, you will probably want to wrap it up in a service.

I did a quick search, I'm sure there are several available FileReader wrappers for Angular available on google, for example, or ng-file-upload.

doug65536
  • 6,562
  • 3
  • 43
  • 53