search

Home  >  Q&A  >  body text

javascript - How to implement txt file browsing function on the website?

We want to make an online reader, which needs to support users to drag in a txt file and then open it for viewing.
How to achieve this?

We searched for some methods on the Internet, and some directly used iframe src="xxx.txt", but when opened, the code was garbled.
Please help me.

ringa_leeringa_lee2827 days ago589

reply all(2)I'll reply

  • 迷茫

    迷茫2017-05-19 10:11:57

    First of all, txt on win is mostly encoded by gbk, and browsers now use utf-8 by default

    You can use ajax to get the txt and then write it to the page

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:11:57

    Txt files are generally not big, you can transfer the file to the server when the user drags it in
    Then it will be parsed by the server and displayed to the front desk

    reply
    0
  • Cancelreply