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 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. 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
Archived
This topic is now archived and is closed to further replies.