dow57588 2015-02-08 18:00
浏览 83

如何在javascript中读取文本文件的最后一个值

I have a server side script which outputs result in a txt file. And the value stored in the txt file is like

1
2
5
7
10

As I want to make a realtime progress bar I have to take last value each time with ajax request while updating the txt file with serverside results. So how can I grab the last value of the file with the help of javascript?

Or, is there any way to save the current value to the file with removing previos value as there will be only one value in the file? I am using php as server side script.

  • 写回答

1条回答 默认 最新

  • duanpiao6679 2015-02-08 18:07
    关注

    Or, is there any way to save the current value to the file with removing previos value as there will be only one value in the file?

    Obviously, yes.

    $result = file_put_contents($path, strval($progress));
    if($result === false) {
      // Error while writing to disk
    }
    

    This will replace the file contents, overwriting all previous values.

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)