PHP: Simplest way to delete a folder (including its contents)

后端 未结 7 2019
刺人心
刺人心 2020-12-08 14:00

The rmdir() function fails if the folder contains any files. I can loop through all of the the files in the directory with something like this:



        
7条回答
  •  一整个雨季
    2020-12-08 14:34

    As per this source;

    Save some time, if you want to clean a directory or delete it and you're on windows.

    Use This:

        chdir ($file_system_path);
        exec ("del *.* /s /q");
    

    You can use other DEL syntax, or any other shell util. You may have to allow the service to interact with the desktop, as that's my current setting and I'm not changing it to test this.

    Else you could find an alternative method here.

提交回复
热议问题