0

I am developing a small application which will search through local CSV file and display the result. This app will be distributed in CDs and is supposed to run from the CD only. To parse CSV file, I am using http://www.papaparse.com . But my problem is As I am trying to access a local file, browsers (basically IE, Firefox, and Chrome) don't allow to access local files via file:///.. I am looking for a solution. Is there any solution for it through Jquery code or something..? I am very new to Jquery ans still not very comfortable with it. My small piece of code is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Search</title>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jquery.parse.js"></script>

<script>   
        $.get("org1.csv", function(text) {
            var data = $.parse(text);
            console.log(data);
        });   
</script>
</head>
<body>
    <span id="content"></span>
</body>
</html>

Any help would be appreciated!

user3405976
  • 51
  • 1
  • 2
  • 8
  • Try one of these and have the user upload the file to you: http://designscrazed.com/html5-jquery-file-upload-scripts/ – Evan Knowles May 09 '14 at 05:39
  • Thanks Evan! But the file is actually a database and user cannot upload it, it should be distributed with the application. – user3405976 May 09 '14 at 05:44
  • If it's distributed with the application, can't you just serve it up from the same location that you're serving your HTML / JS? There are lots of good reasons why browsers won't let pages randomly access files on the client's computer. – Evan Knowles May 09 '14 at 05:47
  • No! I can't do that. It should work in offline mode and this my issue. and it should work on at least three browsers (IE, Firefox, and Chrome). – user3405976 May 09 '14 at 06:00
  • Like @EvanKnowles says, due to security reasons JavaScript (and hence, jQuery) cannot access local files on the client. You probably need a Flash or Silverlight program embedded on the page to achieve this. Again these plugins have security restrictions. Read here: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000451.html – Sreenath H B May 09 '14 at 06:19

0 Answers0