P
P
p1s9p12015-09-30 17:44:49
PHP
p1s9p1, 2015-09-30 17:44:49

PHP script for creating a file in the root of the site (with data) how to implement?

Good day, please help to implement a script that will create a file (with field data) in the root of the site after filling out the form.
for example html code:

<form action="/send.php" method="post">
<div><input autocomplete="off" type="text" name="POLE-1" placeholder="x"></div>
<div><input autocomplete="off" type="text" name="POLE-2" placeholder="x"></div>
<div><input autocomplete="off" type="text" name="POLE-3" placeholder="x"></div>
<div><textarea autocomplete="off" type="text" name="POLE-4" placeholder="x"></textarea></div>
<button type="submit" name="form_submit">Send</button>
</form>

after clicking "Send" the script will create a file in "/tmp/", the file name is the date of its creation, for example " 31-01-2015.ani " inside with content (specified in the fields POLE-1, POLE-2, POLE-3, POLE-4 )

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivanq, 2015-09-30
@p1s9p1

<?php
// Где $value - содержимое файла
file_put_contents($_SERVER["DOCUMENT_ROOT"]."/".date("d-m-Y").".ani", $value);
?>

S
Sergey Melnikov, 2015-09-30
@mlnkv

php.net/manual/en/function.file-put-contents.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question