PHP write to text file
Moderator: General Moderators
- chris98
- Forum Contributor
- Posts: 103
- Joined: Tue Jun 11, 2013 10:47 am
- Location: England, United Kingdom
PHP write to text file
Hello, I am currently working on a website, and I want to create an uploads section.I have got this working, however now I would like to put the Users Username who has uploaded something into a text file in the same location as the upload.I have tried for ages, and was wondering if anyone knows how?
Re: PHP write to text file
Any reason you're not using a database? That's the best place for that kind of information.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: PHP write to text file
Code: Select all
$file = '/path/to/some/file.txt';
$username = 'foobar';
file_put_contents($file, $username);(#10850)
- chris98
- Forum Contributor
- Posts: 103
- Joined: Tue Jun 11, 2013 10:47 am
- Location: England, United Kingdom
Re: PHP write to text file
Thanks, I can get it to work now!