Welcome visitor
* Login
* Register
It is currently September 19th, 2019, 4:45 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Create a file from a textarea
PostPosted: October 22nd, 2009, 1:41 am 

Posts: 27
Is there a way to create a .txt file from a textarea entry?

Thanks for your time.


Top
 Profile  
 
  Re: Create a file from a textarea
PostPosted: October 22nd, 2009, 2:25 am 
User avatar

Posts: 79
You need server side coding.
Here's a simple html form to get a name for the file (no need to enter .txt extension) and a textarea to catch the text for the document
<form name="creating" method="post" action="create_file.php">
<input value="file name" name="name" onclick="this.value='';" />
<textarea name="content" onclick="this.value='';">file content</textarea>
<input type="submit" value="create file" />
</form>

And then there should be a php file on your server called create_file.php with this content:
<?php
extract($_POST);
$name=$name . '.txt';
$filehandler = fopen($name, 'w');
fwrite($filehandler, $content);
?>

Also you will need to have permission by the server to create files.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron