# Access remote file storage

**URL:** <https://discourse.cakephp.org/t/access-remote-file-storage/8659>\
**Category:** Need Help\
**Created:** [November 26, 2020, 5:50am UTC](https://discourse.cakephp.org/t/access-remote-file-storage/8659 "2020-11-26T05:50:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![allnewcake](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@allnewcake](https://discourse.cakephp.org/u/allnewcake)\
**Post date:** [November 26, 2020, 5:50am UTC](https://discourse.cakephp.org/t/access-remote-file-storage/8659/1 "2020-11-26T05:50:57Z")

</div>

I am a novice in programming world. Want to access remote file storage (windows server) from my cakephp application (linux server) using credentials.  
I want to travers the directory and count the number of files in that directory.  
I know how to access folder on same server. But have no idea about remote server access.  
I tried something like this

```
    $path = '\\< IP >;
    $user = "< username >";
    $pass = "< password >";
    $drive_letter = "D"; //this is the drive name that I want to access
    system("net use ".$drive_letter.": \"".$path."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");
    $location = $drive_letter.":/";
    $result = is_dir($location);
    echo $result;

```

But getting a blank page.  
I don’t know whether I am on a right track.

---

<div class="post-metadata">

**Author:** ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)\
**Post date:** [November 26, 2020, 7:23am UTC](https://discourse.cakephp.org/t/access-remote-file-storage/8659/2 "2020-11-26T07:23:40Z")

</div>

Hey mate, welcome to the forums.

I won’t provide an answer to your question as your approach is fundamentally wrong. There are a number of significant security implications in how you’re trying to achieve this. I must assume your windows server is not using SSL (as if it was you wouldn’t be stuck where you are now) thus your traffic will be unencrypted - and you’ll be sending login credentials in plain text through who knows how many servers!

How much control do you have on that Windows Server? Is it hosting a PHP implementation? In which case develop for yourself a private API you can talk to, using your own CSRF protection in doing that. Then that API can respond to requests such as a directory listing.

Or else, you could do a push from the Windows Server to your application, using a [long] polled AJAX, so that the data you need which is on that server is duplicated locally in your CakePHP app - and changes on the server are reflected by posting those back to your CakePHP app.

Or, you could try using net sockets.

You must employ SSL regardless your approach.

I know these are only generic responses, not like working code of how-to, it’s just I feel you need to rethink how you should achieve your goal here.

---

<div class="post-metadata">

**Author:** ![allnewcake](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@allnewcake](https://discourse.cakephp.org/u/allnewcake)\
**Post date:** [November 26, 2020, 7:32am UTC](https://discourse.cakephp.org/t/access-remote-file-storage/8659/3 "2020-11-26T07:32:52Z")

</div>

Thankyou for the valuable information. I’ll try to dig into…

---

<div class="post-metadata">

**Author:** ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)\
**Post date:** [November 26, 2020, 8:23am UTC](https://discourse.cakephp.org/t/access-remote-file-storage/8659/4 "2020-11-26T08:23:10Z")

</div>

It also occurs to me, I mean if you’re not comfortable in learning and programming to that extent, you can get away with a mostly safe & hacky solution, which is to put a FTP server on the Windows box. Then you can do what you need with just bash scripts or PHP. Again though, must have end-to-end encryption, SSL (so it’ll be SFTP).

---

<div class="post-metadata">

**Author:** ![allnewcake](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@allnewcake](https://discourse.cakephp.org/u/allnewcake)\
**Post date:** [November 26, 2020, 10:17am UTC](https://discourse.cakephp.org/t/access-remote-file-storage/8659/5 "2020-11-26T10:17:38Z")

</div>

Oh thankyou… I am also trying the same
