Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am running a javascript code,where i am taking a file from the local disk and then trying to open or read the file. Javascript code is as follow:

JavaScript
var CSVfilepath = prompt("Enter the path of CSV file","D:/BlackPanther/LudhiyanakOL.csv");
var ReadCSVfile = new file(CSVfilepath);
ReadCSVfile.open(CSVfilepath);
ReadCSVfile.readln();


I am getting error in var ReadCSVfile = new file(CSVfilepath) that file is undefined.
Why i m getting file undefined message?

Any help would be appreciated.


Thanks.
Posted
Updated 27-Jun-12 20:47pm
v2

1 solution

XML
var CSVfilepath = prompt("Enter the path of CSV file","D:/BlackPanther/LudhiyanakOL.csv");
var ReadCSVfile = new file(CSVfilepath);

I doubt if you can access files like this in Javascript. Due to security reasons direct access to files are not supported.

Possible alternative to access file from Javascript are ActiveX, Silverlight, Flash, etc.

Further, if you want to access some data from files stored on the server then you can use XMLHttpRequest to get back the contents of that file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900