简体   繁体   中英

How to get contents of a file on my computer from my website?

I want to get the contents of a file on my computer from my website , But not uploading it to that website and then get the contents because the file contents changes dynamically , I tried to turn the folder that contains that file to a URL so the URl whould be something like that : http://127.0.0.1:port or http://myIpAddress:port ,

and tried to use both file_get_contents() and cURL but I got errors and they are not working ,
I allowed xmlHTTPrequest to the directory but still can't use it .

Some of the errors:

when using 127.0.0.1:port :
1- file_get_contents(): failed to open stream: Connection refused
2- curl faild to connect to 127.0.0.1

when using my ip then the port:
1- file_get_contents no route to host
2- curl bool(false)

So is there is another way to get contents from a file from my website ?

In your server CD to directory you want to serve, then

python3 -m http.server

By default it runs http server on 8000 port but you can specify custom port in argument

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM