Warptweet Posted January 7, 2007 Share Posted January 7, 2007 Pretend I have a form...Flash Name: _ _ _ _ _ _And in process.php, it creates a file using the inputted name...[code]$ourFileName = $_POST['flashname'];$ourFileHandle = fopen($ourFileName, 'w') or die("Sorry, cannot create file.");fclose($ourFileHandle);[/code]Of course, in this case it is creating a file.Although, when it creates a file from what the user typed inside the form field, is the file create as a .txt file? Whats the default file extension when a file is created and written in? If not, then how can I improvise that code so that the file name is $ourFileName, but with .txt extension? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 7, 2007 Share Posted January 7, 2007 There is no default file type when you create a file. If you want to create a file with a "txt" file type you need to give it one:[code]<?php$ourFileName = $_POST['flashname'];$ourFileHandle = fopen($ourFileName . '.txt', 'w') or die("Sorry, cannot create file.");fclose($ourFileHandle);?>[/code]Ken Quote Link to comment 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.