Page 1 of 1

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

Posted: Wed Apr 29, 2009 1:14 pm
by selvamdoom
Hi
i want to create a txt file in client computer using php or javascript. how to create??

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

Posted: Thu Apr 30, 2009 2:05 am
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.

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

Posted: Thu Apr 30, 2009 2:10 am
by Benjamin
Heads for PHP - Code, Tails for Javascript...

Tails!

:arrow: Moved to Javascript

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

Posted: Fri May 01, 2009 2:27 am
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
}