Notepad Script using “textarea”
Notepad is a simple text editor from Microsoft, which is included in all versions of Windows. You will find bellow a simple notepad in browser using “textarea” you can also save that text as textfile like audain.txt
when we click the button in the dialog.
This PHP script is useful to export page content in text format. For this example,we will save “content” name field to a text file
*/
<?php
if (!empty($_POST)) {
$content = $_REQUEST[‘content’];
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=’ . basename(‘file.txt’));
echo $content;
exit;
}
?>
/*
End
*/
<!DOCTYPE html>
<html lang=”en”>
<head>
<title>Download File</title>
<meta charset=”utf-8″>
/*
Responsive form
*/
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js”></script>
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
/*
End
*/
</head>
<body>
<div class=”container”>
<form action=”” method=”post”>
<div class=”form-group”>
<textarea name=”content” required placeholder=”Content…” rows=”20″ id=”content” class=”form-control”></textarea>
</div>
<div class=”form-group text-right”>
<button type=”submit” class=”btn btn-primary”>Download</button>
</div>
</form>
</div>
</body>
</html>