how to create a txt file in client side using php or js

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
selvamdoom
Forum Newbie
Posts: 7
Joined: Wed Apr 29, 2009 12:53 pm

how to create a txt file in client side using php or js

Post by selvamdoom »

Hi
i want to create a txt file in client computer using php or javascript. how to create??
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: how to create a txt file in client side using php or js

Post by it2051229 »

i'm not sure but as far as i can remember you can't do that.. BUT you can display the data into the client's browser which can be saved by the client as a text file.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: how to create a txt file in client side using php or js

Post by Benjamin »

Heads for PHP - Code, Tails for Javascript...

Tails!

:arrow: Moved to Javascript
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: how to create a txt file in client side using php or js

Post by kaszu »

You can create a file and pass it to user for download (can't set filename, at least I'm don't know how), but you can't create it on clients computer.

Code: Select all

function downloadTxtFile (str) {
    document.location.href = 'data:application/data;charset="utf-8",' + str;
    //Using incorrect mime type because text/plain will open it in browser instead of showing download
}
Post Reply