Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
All am trying to do is to copy whatever is in my console output
to a textfile-"blob.txt"

Now what is happening is I get a textfile generated successfully.
But the content is not what is on my console. Rather THE TEXTFILE JUST HAS **[object object]**

Below is my code..can someone tell me what am doing wrong?

Note-fileData is the string that am storing content that gets populated on the console.

Thanks, in advance!!

JavaScript
var a = window.document.createElement('a');
    a.href=window.URL.createObjectURL(new Blob([fileData],{type:'filename/txt'}));
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);


What I have tried:

var a = window.document.createElement('a');
    a.href=window.URL.createObjectURL(new Blob([fileData],{type:'filename/txt'}));
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
JavaScript

Posted
Updated 8-Feb-21 13:28pm
v5

1 solution

Again, Javascript running in a browser does not have the ability to read/write files on the client workstation. All client-side resources, including the file system, are off-limits to code running in a browser.
 
Share this answer
 
Comments
ekonapikin1990 10-Feb-21 16:45pm    
Sir-thank you, I have tried everything I can to no avail I am unable to copy console output to any file -the file just has [object object].
So am beginning to think you re right, but is there any solution to for me to achieve my goal?
Gave *3 because I believe nothing is impossible!!
Dave Kreskowiak 10-Feb-21 16:46pm    
How many times do you me to tell you there is no way to do it?
ekonapikin1990 10-Feb-21 16:48pm    
any other way I can do this?
am actually parsing pdf data to the console, and is thesame data I am trying download a text file. Was wondering if you have any suggestion sir
Dave Kreskowiak 10-Feb-21 16:56pm    
You're only hope is to upload the PDF to the server, have the server do the parsing and generate a file to send back to the client to download. The client doesn't do any of the work and the text file can be downloaded and saved on the client machine by the browser.
ekonapikin1990 10-Feb-21 17:01pm    
Awesome, thank very much sir!!

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