mikelmao Posted October 8, 2008 Share Posted October 8, 2008 Hey, How do i create a NON EXISTING file? I want my script to Create a .TXT file.. Please help me Thanks Quote Link to comment https://forums.phpfreaks.com/topic/127524-solved-create-a-non-existing-file/ Share on other sites More sharing options...
Orio Posted October 8, 2008 Share Posted October 8, 2008 Using fopen(). <?php $filename = "newfile.txt"; if(file_exists($filename)) echo "Already exists"; else { $h = fopen($filename, "w+"); echo $filename." created!"; } ?> If what you're looking for is a way to create a file with an unique name you can use tempnam(). Orio. Quote Link to comment https://forums.phpfreaks.com/topic/127524-solved-create-a-non-existing-file/#findComment-659779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.