It's possible save a string as text file and save the file on desktop?
I have found only questions about ow to save the file in the server.
I've tried but without luck
It's possible save a string as text file and save the file on desktop?
I have found only questions about ow to save the file in the server.
I've tried but without luck
You cannot force the download location of a file on a users computer, but you can force download a file prompt and have the user choose where to put the file.
This seems to be similar to the following question, where the answer is to 'force download' the file:
$file_url = 'http://www.myremoteserver.com/file.txt';
header('Content-Type: text/plain');
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\"");
readfile($file_url); // do the double-download-dance (dirty but worky)
//CREATE
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
//WRITE
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);
PHP is server side.
But you could output a .txt file as download. Saving location will be defined by the user.
Check this: http://www.richnetapps.com/the-right-way-to-handle-file-downloads-in-php/