0

I have a file which is at a network which looks like this -

\\\mangoes.txt

I want to read this file directly without using any input tag on the html page.

how can I achieve this?

tusharmath
  • 10,622
  • 12
  • 56
  • 83

1 Answers1

1

This is not possible. Browsers wont allow you reading any file other than JS or CSS. This would be a breach of security. Using form however you can ask user to updload a file and then can read the content of that file. But this is not possible without using input tags. For a workaround following options are possible :

  1. You can send AJAX call to your server which would then read the file and will send you the text of the file in response.
  2. You can use a JS file and ca\n keep all your data in a variable and then can use the data in that variable by including JS file in your HTML page.
  3. You can keep the data into a hidden div on HTML page itself and can read its value using Java Script.
Amber
  • 1,229
  • 9
  • 29