Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client side file creation and download

We are using fusioncharts and it has the ability using javascript on the client side to export csv data, we want to be able to take that data and create a file on the fly in the browser. is that possible? How?

like image 857
arinte Avatar asked Feb 24 '11 17:02

arinte


People also ask

How do I force download a link instead of open?

In most browsers, clicking on the link will open the file directly in the browser. But, if you add the download attribute to the link, it will tell the browser to download the file instead. The download attribute works in all modern browsers, including MS Edge, but not Internet Explorer.


1 Answers

Try below code allow you to access client side file system but this works only in IE browser

<html>
    <body>
    <script language="JScript">
    <!--
    function getsize()
    {
        var myObject, afile, size;
        myObject = new ActiveXObject("Scripting.FileSystemObject");
        afile = myObject.GetFile("c:\\test.txt")
        size = afile.Size;
        alert("The size of the test.txt file is:" + size);
    }
    -->
    </script>
    Get the size for the file "test.txt"
    <form name="myForm">
    <input type="Button" value="Get Size" onClick='getsize()'>
    </form>
    </body>
    </html>
like image 194
Pranay Rana Avatar answered Oct 11 '22 16:10

Pranay Rana