Download html textarea content as a file

Downloading Textarea Contents in txt format using PHP, Downloading Textarea Contents using PHP

Hi guys today i will tell you through this tutorial that you are downloading the value of textarea by php.

textarea.php

<?php
if(isset($_POST['text']))
{
header('Content-disposition: attachment; filename=test.txt');
header('Content-type: application/txt');
echo $_POST['text'];
exit; //stop writing
}
?>

<html>
<body>
<form action="" method="post">
<textarea name="text" rows="20" cols="100"></textarea>
<input type="submit" value="submit" name="submit">Download Text</input>
</form>
</body>
</html>