0

I wanna set the name of the file with a input field. I already know you could such thing with a variable you need to set yourself

I tried this but it didnt work and I could find anything on the web either about this

$location
$ret = file_put_contents('/tmp/$_POST[$location].txt'

please help

1
  • try this file_put_contents('/tmp/'.$_POST["location"].'txt' Commented Jan 1, 2014 at 14:21

1 Answer 1

1
$location = $_POST['location'];
$ret = file_put_contents("/tmp/$location.txt", $data);

You also need to set the second parameter (data).

But it is not such a good idea to use this and have you thought about duplicate names? If someone posts a name that already has been used.

https://www.php.net/file_put_contents

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.