0

Title. This is my first time working with CSV's, and I'm following tutorials to the letter yet I keep getting errors:

d3.v4.min.js:2 Not allowed to load local resource: file:///C:/Users/User1/Desktop/Project/data.csv

This is pretty much my function:

    <script> 
                    
    d3.csv("C:/Users/user1/Desktop/data.csv", function(data)
    {
      console.log(data)
    })


    </script>

I even tried putting the CSV file in the same directory but it gives me a 404: dashboard:149 GET http://localhost:8000/account/views/account/data.csv 404 (Not Found)

    <script>  
        d3.csv("views/account/data.csv", function(data){
      console.log(data)
    })

    </script>

d3.v4.min.js:2 GET http://localhost:8000/views/account/data.csv 404 (Not Found)

Even tried putting it in the Root directory of the project. Gives me the 404... Help?

user9583887
  • 33
  • 1
  • 7
  • Are you trying to fetch a file outside the web server directory? Because you're not allowed to do that for a myriad of reasons. First upload the file to your web server (locally or otherwise), then fetch the file from there. The only way web app is ever allowed to get files from a personal directory is if the user performs an upload action of sorts. Otherwise, you cannot target personal storage drives. – Martin Jul 03 '20 at 20:07
  • @Martin When you say web server directory you mean the root directory of the project right? I did place the file in the root directory of the project. – user9583887 Jul 03 '20 at 21:12
  • Yes, I mean anywhere outside of your web server folder, i.e. www folder in wamp or what else web server you're running locally. – Martin Jul 03 '20 at 22:06
  • Yes, I mean anywhere outside of your web server folder, i.e. www folder in wamp or what else web server you're running locally. – Martin Jul 03 '20 at 22:07
  • I don't quite know what you mean by fetching the file. Since I keep getting the errors i'm clearly doing something wrong, even having the file in the project directory, and not in like Desktop or whatever. – user9583887 Jul 03 '20 at 22:58
  • Are you running a local web server? I.e. WAMP or XAMPP etc. ? If yes, you can't access files outside of that directory as a web server does not have read or write permissions to personal drives (for a good reason). In WAMP, that directory is called `www`. For instance `C:\wamp64\www` if you installed it on the *C* drive. – Martin Jul 04 '20 at 12:38

0 Answers0