This topic is locked

Copy files from external location (NAS file server) to a local PC - triggered from PHPRunner

12/22/2021 10:25:15 AM
PHPRunner General questions
R
rogerB author

What is the best solution to copy a folder or selected files from a NAS server to the local PC running PHPRunner application, and vice versa, triggered by buttons? Event code in PHPRunner, or external script, or other solution?

K
kohle 12/22/2021

Hi,
I believe you should take a look at the function: copy()

Input :
$source = 'Source_file_location'
$destination = 'Destination_file_location'

copy( $source, $destination )

Output: true

More infos you find in the web

Sergey Kornilov admin 12/22/2021

Yes, PHP's copy() function will do the job. Here is the link to their manual.

R
rogerB author 12/28/2021

Dear Sirs!
Pardon my lack of programming knowledge, but I did the following:

  1. Created a custom button.
  2. Inserted the code in Client After, because both source and destination directories are available on the local drive, and not on the server.
  3. I put test files in folder ...\Fra

Code in Client After:
$source = 'C:\Users\roger\OneDrive\Documents\Test\Fra\Fra.txt';
$destination = 'C:\Users\roger\OneDrive\Documents\Test\Til\Til.txt';
copy($source, $destination);

Any idea what could be wrong?

Sergey Kornilov admin 12/28/2021

ClientBefore and ClientAfter event cannot copy any files, these are Javascript events that work solely in the web browser. Your code needs to be added to the Server event.

You need to start by reading this article on tri-part events. You need to have at least a basic understanding of hwo things work.