如何从Php + Jquery中的文件夹中获取所有文件[关闭]

For Example i have One folder With Name

 Main Folder----| 
                 |
                 |
        |-----------------------|                
        |                       |
        |                       |
    Sub Folder 1              Subfolder 2
         |                      |
  |---------------|             |
  |               |          file 3.rar   
  |               |
file1.rar     file 2.rar

Now I need To Reduce all necessaory Folder andNow I need Final Output Like Below is that Possible ?

 Main Folder
     |
     |
  file1.rar
  file2.rar
  file3.rar  

What you're looking for is scandir or glob within PHP. These should give you a good starting point on how to run through directories, find files then copy or rename (this doesn't just rename files, it can be used to move them too) the files to their final destination.