d3.js - How to follow a symbolic link using javascript? - Stack Overflow

I'm running python -m SimpleHTTPServer 8888 from the directory my_serverand I want to access index

I'm running python -m SimpleHTTPServer 8888 from the directory my_serverand I want to access index.html file that contains a javascript mand that reads my_file.csv, but the file is not in my_serveror one of its subfolders.

path/to/my_server $ ln -s /some_path/to/my_file.csv symbolic_link_to_my_file.csv
path/to/my_server $ python -m SimpleHTTPServer 8888

If I create a symbolic link inside my_server that points to my_file.csv and then access it like this:

http://localhost:8888/my_server/index.html?file=symbolic_link_to_my_file.csv

is there any way I could follow this symbolic link with javascript inside index.html to read my_file.csv?

<script>
    //read URL params
    ...
    d3.csv(file, ...)
</script>

I'm running python -m SimpleHTTPServer 8888 from the directory my_serverand I want to access index.html file that contains a javascript mand that reads my_file.csv, but the file is not in my_serveror one of its subfolders.

path/to/my_server $ ln -s /some_path/to/my_file.csv symbolic_link_to_my_file.csv
path/to/my_server $ python -m SimpleHTTPServer 8888

If I create a symbolic link inside my_server that points to my_file.csv and then access it like this:

http://localhost:8888/my_server/index.html?file=symbolic_link_to_my_file.csv

is there any way I could follow this symbolic link with javascript inside index.html to read my_file.csv?

<script>
    //read URL params
    ...
    d3.csv(file, ...)
</script>
Share Improve this question edited May 16, 2012 at 22:14 Jamund Ferguson 17k3 gold badges45 silver badges51 bronze badges asked May 16, 2012 at 22:01 nachocabnachocab 14.5k21 gold badges104 silver badges159 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

JavaScript, running in the browser, has no access to the file system at all (for that matter, nor does anything else in the browser).

The client only sees URIs.

It is the responsibility of the webserver to serve up the appropriate resource for the URI.

You need to edit / configure SimpleHTTPServer to follow the symlink and / or make sure the user the server is running at has permission to access the file at the other end of the link.

Reading the docs on the d3.csv mand you need to send it a full URL. https://github./mbostock/d3/wiki/CSV

What is the value of file in the d3.csv(file mand? If you're sending it something like "filename.csv", it may just be appending that to your current URL or current directory. You probably want to send it a full URL like this (with a slash at the beginning): /folder/myfile.csv

If you type this URL into your browser does it give you the CSV file? http://localhost:8888/my_server/index.html?file=symbolic_link_to_my_file.csv

If it does then the contents of file should probably be /my_server/index.html?file=symbolic_link_to_my_file.csv.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745360580a4624338.html

相关推荐

  • d3.js - How to follow a symbolic link using javascript? - Stack Overflow

    I'm running python -m SimpleHTTPServer 8888 from the directory my_serverand I want to access index

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信