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.
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
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