Jump to content

[SOLVED] Create File On Click..


napalm

Recommended Posts

is there a way to create a file once a button is created?

 

like have a button and when it is clicked it creates a html file into a directory?

 

and possibly have a button when the button is clicked to create it

 

have it so it changes to a remove button and it removes the html file?

Link to comment
Share on other sites

No im pretty sure you can do this in php

yeah i know fwrite.. but thats only when u vist the page it creates it

im wondering if theres a way for when u click a link it does it?

 

Yes!  Make a link to a .php page and use the information in the links I gave you.

Link to comment
Share on other sites

nono....

 

like:

<form action="" method="post">

  <input type="button" name="create" value="create_file">

</form>

<?php

 

  if (isset($_POST['create'])) {

  $create = "File.html";

  $create = fopen($create, 'w') or die("can't open file");

  fclose($ourFileHandle);

 

  }

 

?>

 

????

Link to comment
Share on other sites

This kid is not going to learn anything if you just give him the code.

 

Pipe down, it was a simple example.

 

nono....

 

like:

<form action="" method="post">

  <input type="button" name="create" value="create_file">

</form>

<?php

 

  if (isset($_POST['create'])) {

  $create = "File.html";

  $create = fopen($create, 'w') or die("can't open file");

  fclose($ourFileHandle);

 

  }

 

?>

 

????

 

Is that meant to be a question?

Link to comment
Share on other sites

Pipe down, it was a simple example.

 

Sorry, but when someone starts a thread on how to create a file and doesn't even know how to create a submission button, it makes me think he just wants a CnP solution...  And in-case you couldn't figure out the delete part:

 

if (isset($_POST['create'])) 
{
$create = "File.html";
$create = fopen($create, 'w') or die("can't open file");
fclose($ourFileHandle);
}

if (isset($_POST['delete']))
{
$delete = "File.html";
unlink($delete);
}
?>

</pre>
<form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" method="post">
  
  
<

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.