How to use PHP & Fopen() Create New File Learn how to use the PHP to Create New File on web server.
ShotDev Focus:
- PHP & Create New File
Example
php_create_file.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $strFileName = "shotdev/my.txt"; $objCreate = fopen($strFileName, 'w'); if($objCreate) { echo "File created."; } else { echo "Cannot create file."; } fclose($objCreate); ?> </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_create_file.php
Screenshot