file - How to create folder with PHP code? -


can create folder php code? want whenever new user create new account folder automatically creates , php file created.is possible?

purely basic folder creation

<?php mkdir("testing"); ?> <= this, creates folder called "testing".



basic file creation

<?php $file = fopen("test.txt","w"); echo fwrite($file,"hello world. testing!"); fclose($file); ?> 

use a or a+ switch add/append file.



edit:

this version create file , folder @ same time , show on screen after.

<?php  // change name below folder want $dir = "new_folder_name";  $file_to_write = 'test.txt'; $content_to_write = "the content";  if( is_dir($dir) === false ) {     mkdir($dir); }  $file = fopen($dir . '/' . $file_to_write,"w");  // different way write content // fwrite($file,"hello world.");  fwrite($file, $content_to_write);  // closes file fclose($file);  // show created file created folder on screen include $dir . '/' . $file_to_write;  ?> 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -