Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php how to create file in specific directory

Tags:

php

How would I create a file in a specific directory?

this is my code at the moment :

$username = $_POST["username"];

$filedir = "./u/".$username;

mkdir($filedir);

$folder = $filedir;
chmod($filedir, 0777);

$createfile = fopen( $_SERVER['DOCUMENT_ROOT'] . '/path/filename.php' );

I have also tried fopen but that didn't work :(

I HAVE GOT IT!!! It was

$createfile = fopen('./u/'.$username.'/'.$username.'.php', 'x');

Thanks for all the help guy :) really appreciated.
like image 524
meme Avatar asked Oct 08 '16 11:10

meme


1 Answers

Answer was this :

$createfile = fopen('./u/'.$username.'/'.$username.'.php', 'x');

Thanks for all the help guy :) really appreciated.
like image 108
meme Avatar answered Oct 07 '22 02:10

meme