使用 PHP 或浏览器访问由 NodeJS 模块创建的文件

Access file created by NodeJS module using PHP or browser

我已经在 Digital Ocean Droplet 上安装了 NodeJS module。它生成一个我存储在目录 root/csv_file/my_file.csv.

中的 csv 文件

但是,我无法通过简单地访问ip_address/csv_file/my_file.csv在浏览器中访问它。

read this question 要求我安装 http-server 所以我安装了它。之后我 运行 以下命令:

http-server csv_file

http-server root

但是,none 允许我通过访问 root/csv_file/my_file.csv 来访问该文件。

在 PHP 中使用 file_get_contents() 函数会出现以下错误:

No connection could be made because the target machine actively refused it.

如何最好地在 PHP 或浏览器中访问此文件?

谢谢。

默认情况下,

http-server csv_file 将在端口 8080 中提供服务。 你试过了吗http://your_ip_address:8080 请确保:端口已经是 opened/allowed (https://askubuntu.com/questions/911765/open-port-on-ubuntu-16-04)