create file in another directory with php

后端 未结 5 1203
一生所求
一生所求 2021-02-01 21:51

My folder structure is like -

root
  admin
    create_page.php
  pages
    my_page1.php
    my_page2.php

I have code for creating a new php fi

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 22:12

    Here's an example using the more simpler file_put_contents() wrapper for fopen,fwrite,fclose

    ';
    
    if (file_put_contents($newFileName, $newFileContent) !== false) {
        echo "File created (" . basename($newFileName) . ")";
    } else {
        echo "Cannot create file (" . basename($newFileName) . ")";
    }
    ?>
    

提交回复
热议问题