Page 1 of 1

fopen("$var/index.php","x") doesn't work

Posted: Tue Oct 25, 2011 8:57 am
by Jackount

Code: Select all

		$file = fopen("./$l/index.php",'x');
I'm calling the above function, wanting to create a file, that does not exist already. It worked before I made the $l be a folder, when $l was the filename ( fopen("$l.php",'x'); )

Code: Select all

		$file = fopen("./".$l."/index.php",'x');
^^ Doesn't work either...

Re: fopen("$var/index.php","x") doesn't work

Posted: Tue Oct 25, 2011 9:05 am
by Celauran
Try using is_dir() to see if the directory exists, then create it if necessary.

Re: fopen("$var/index.php","x") doesn't work

Posted: Tue Oct 25, 2011 9:09 am
by Jackount
Well, I KNOW the directory doesn't exist? I just want to create the file in that given foldername... should be possible ;o

Re: fopen("$var/index.php","x") doesn't work

Posted: Wed Oct 26, 2011 4:48 am
by martelo59
I'm calling the above function, wanting to create a file, that does not exist already.
Whay you dont use fwrite and make "w+" for writing, that function will make your file. If you don't have created directory first use mkdir, after this fwrite.