OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Using Javascript FileReader with huge files

  • Thread starter Thread starter ssamuel68
  • Start date Start date
S

ssamuel68

Guest
I have a problem using the Javascript FileRead trying to read huge files.

For example, I have a text file of 200mb and everytime I read this file the code stops working.

Its possible to read the text file, but for example ONLY the first 10 lines or stop reading after 10mb?

This is my code:

Code:
var file = form.getEl().down('input[type=file]').dom.files[0];
var reader = new FileReader();

reader.onload = (function(theFile) {
                return function(e) {
                    data = e.target.result;
                    form.displayedData=data;
                };
            })(file);

reader.readAsText(file);

The e.target.result always has the whole data of the file.

What can I do here?

Thx

<p>I have a problem using the Javascript FileRead trying to read huge files.</p>

<p>For example, I have a text file of 200mb and everytime I read this file the code stops working.</p>

<p>Its possible to read the text file, but for example ONLY the first 10 lines or stop reading after 10mb?</p>

<p>This is my code:</p>

<pre><code>var file = form.getEl().down('input[type=file]').dom.files[0];
var reader = new FileReader();

reader.onload = (function(theFile) {
return function(e) {
data = e.target.result;
form.displayedData=data;
};
})(file);

reader.readAsText(file);
</code></pre>

<p>The <code>e.target.result</code> always has the whole data of the file.</p>

<p>What can I do here?</p>

<p>Thx</p>
 
Top