I have a textarea, text input and a button wich sends textarea and text input values (using AJAX post method) to PHP site. Now, I want PHP to output textarea value as .txt file so that it can be download via browser.
My PHP code looks like this:
$text=trim($_POST['text']); // textarea value
$fileName=$_POST['fileName'].".txt"; // text input value
header("Content-Type: text/plain");
header('Content-Disposition: attachment; filename="'.$fileName.'"');
header("Content-Length: ".mb_strlen($text));
print($text);
Nothing happens, so can you help me please. Thanks. :)