spyke01

Member
Sep 24, 2013
15
0
1
cPanel Access Level
Root Administrator
I am trying to copy all the files in 1 directory to another without the need to zip, copy, then extract. I have the following code:

PHP:
print $xmlapi->api2_query($account, 'Fileman', 'fileop', array( 'op' => 'copy', 'sourcefiles' => '/public_html/1000b0004', 'destfiles' => '/public_html/test' ) );
This copies the files but it actually copies it to this file structure: /public_html/test/1000b0004 . How can I copy the files over and drop them into the 'test' folder
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
I don't believe that copy directory is an option in the cPanel File Manager. There's no option to copy a directory in the UI and the API call states that sourcefiles should be a comma-delimited list so it doesn't appear to be a recursive copy.

Out of curiosity, why not just use FTP instead of the cPanel API? ftp_put has some code samples for copying directory structures.
 

spyke01

Member
Sep 24, 2013
15
0
1
cPanel Access Level
Root Administrator
I don't believe that copy directory is an option in the cPanel File Manager. There's no option to copy a directory in the UI and the API call states that sourcefiles should be a comma-delimited list so it doesn't appear to be a recursive copy.

Out of curiosity, why not just use FTP instead of the cPanel API? ftp_put has some code samples for copying directory structures.
This would be a nice solution for us in some cases but we have a client that has several directories around 200MB or more, with FTP it doesn't appear that we can copy from one remote directory to another remote directory so we'd have to download the files then re-upload. Alternatively a combination of FTP to get a list of the files and then using the API with the comma delimited list to copy them might work.

or easier yet just use ssh and use the

cp-r

command
This actually looks like a good way to accomplish this quickly. We will probably use the ssh2 php commands. Thanks for the heads up.