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? Link to comment https://forums.phpfreaks.com/topic/33185-quick-variable-question/ 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 Link to comment https://forums.phpfreaks.com/topic/33185-quick-variable-question/#findComment-154882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.