PHP
if($_SERVER['REQUEST_METHOD']=='POST'){
$content = $_POST['meuTextarea'].PHP_EOL;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
// Indica o nome do arquivo como será "baixado". Você pode modificar e colocar qualquer nome de arquivo
header('Content-disposition: attachment; filename=arquivo.txt');
//header('Content-Length: '.strlen($content));
//header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
//header('Expires: 0');
//header('Pragma: public');
echo $content;
exit;
}
HTML to create content
<form action="" method="post">
<textarea name="meuTextarea">5s6a56sa565sa65a6s56sa565sa656sa565sa656as56sa556as5as</textarea>
<p><input type="submit" value="Gerar/enviar"></p>
</form>
Just a curiosity, what’s the point?
– user60252
When I need to generate a csv file or spreadsheet with database data
– Thiago