View Full Version : Copying files to network drives

2019-11-06, 13:25
Hi guys

We are trying to copy a file from our app to a network folder.

It works fine in dev but doesn't in web.

We understand that browsers are sandboxed but this is a server side procedure so we assume it should.

We are trying to do :

lsourcefile = "C:\Lianja\cloudserver\tenants\public\wwwroot\abcte st.txt"
ldestination = "W:\Testfolder\abctest.txt"

copy file (lsourcefile) to (ldestination)

Web page inspector doesn't like this - it throws all sorts of Lianja issues.

Is there something we have missed?

Thanks in advance


2019-11-06, 15:05
Hi Simon

Assuming that is in a server side proc that you are calling from the client using Lianja.evaluate() then there will be no errors on the client from calling this.

You need to verify that the permissions for w: allow you to copy files to it from the cloud server.

You can test this interactively in the browser from the JavaScript console.

2019-11-06, 16:10
Thanks Barry

Had a look at this,even changed backslashes for forward slashes, just in case but always the same.

Works fine in Dev.

Attached is some of the browser red stuff !!


We are not really sure what this means

Yes it is a serverside VFP procedure and the source file exists.

Any ideas?



2019-11-06, 18:37
Hi Simon,

I like to have server side actions on the network test for all possible network issues. .

In this case, I would have the prg first check for the folder where the file is being copied. E.g.,

// movefile.prg
lparameters tcPathedFromFile, tcPathedToFile

// Here I would check that the From file exists

lcPathedFolder = justpath(tcFile)
llDirOK = directory(lcPathedFolder)
if !llDirOK
? "Houston, we have a problem"
return "Folder Not Reachable"

/* Note: here I put in tests for copying a test file with nothing in it and a .txt suffix to the pathed folder and then being able to see it there.
That way I know I can check whether the copying worked,
That testing also will show up anti-virus file extension permissions issues. */

copy file (tcPathedFromFile) to (tcPathedToFile)

// check that the file move worked

return "true"

It's a PITA to have to get on a customer's network to find out my files aren't moving -- and then find out they decided, e.g., that the right permissions aren't there. I write these routines up as library routines: write once, use many. I log all errors to an error database, and access the database from a web app. Saving Support time, whether it mine or a support colleague, is aggravation and money saved.



2019-11-06, 19:53
You don’t need to change backslashes you are running on windows.

Looks like your server proc is failing with an error and you are not handling it in a try / catch which you can do in JavaScript on the client and in your server code.

As a mentioned earlier. You can test this in the console.

When running in dev mode you are most likely running as an administrator.

Running in the web, your code is running under the cloud server which is a service not running as administrator. So you need to open up permissions on your w: drive.

Another thing to bear in mind. This is running as a multi user application so many users can be running your code at the same time. Using a copy of a known filename is not going to work, You need to use unique filenames. That’s a design flaw in what you are doing.

2019-11-06, 23:05
Thanks for the replies guys

Hank - yes testing everything is there before a copy makes good sense.

Barry - Agreed about filenames - we are using filenames based on :

lfilename = substr(juststem(SYS(2015)),2,12) + '.csv' which seems to provide uniqueness.

We always test in the console when we are trying to get things to work as a scratch pad but earlier you said "You can test this interactively in the browser from the JavaScript console" which we don't understand. Could you please clarify.

Going to put this in a TRY/CATCH for safety's sake. It sounds like a permissions issue.

Thanks guys


2019-11-06, 23:24
Hi Simon,

To test in the browser javascript console see below. I'm using chrome so if you a different browser tell me which and i'll show you.

For chrome.


2019-11-07, 01:57
the server have the network drive mapped as "W:"? the same of the client?


2019-11-11, 09:13
Aha !!

Never knew you could do that !!

Already proved useful