0

If i have the file on local server like XAMPP/htdocs/graph.json it works fine. What i want to do is to make a form where i can submit a custom json file, and javascript reads that file.

XAMPP with Apache running. I have my file in XAMPP/htdocs named graph.json. It is hard coded.

I have the following in my index.html:

d3.json("graph.json", function (error, json) {

...
}

I have tried this and at first sight this is exactly what i want

<form action="/index.html">
   <input type="file" name="graph">
   <input type="submit">
 </form>

When i select the json and click "submit" it says "object not found"

Matthew K.
  • 31
  • 4

1 Answers1

0

If you truly want to upload your file to a server, check out this question on how to do that correctly. Note that you need to add some server-side logic handling the upload request to do that. how to upload a file to my server using html

An easier way for you may be a textarea where you paste the JSON content and then read it from D3.

hlidka
  • 2,086
  • 1
  • 15
  • 14