rpjd Posted March 31, 2011 Share Posted March 31, 2011 I'm using a php $_POST variable as the name of a file that I want to create. fopen() , according to my understanding open the file if it exists or creates it if it doesn't. $Ref = $_POST['Ref']; I using each reference element of $Ref as the name of a file in a certain directory. So if $Ref[$i] exists as a file name in a certain directory, append to the file, if it doesn't create the file in that directory and write to it. Do I use the file path of the file within fopen()? fopen(./References/$Ref,a) or fopen(./References/$Ref,w)? Link to comment https://forums.phpfreaks.com/topic/232281-create-file/ Share on other sites More sharing options...
sunfighter Posted March 31, 2011 Share Posted March 31, 2011 Yes, use the file path of the file within fopen(), BUT use the append mode. The w will over write an existing file, the a will add to it or if it creates it just write to it.. ref = http://us3.php.net/manual/en/function.fopen.php Link to comment https://forums.phpfreaks.com/topic/232281-create-file/#findComment-1195283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.