lundi 30 septembre 2019

How do I store files to a another location outside of Laravel 5.5 file structure

Hi first time posting here, I am developing an application using laravel 5.5 and currently uploading files in the public/storage directory using the symlink command. The application is hosted on an application server which is part of my organization's domain/network.

What I would like to do is save my files on another server already dedicated to file storage so as to ease up traffic on the application server.

I have created an 'FTP' configuration in the 'disks' array of config/filesystems.php as I saw in other examples but when the upload is executed I get "Could not connect to host: xx.xx.xx.xx on port 21". Below is the FTP config I added.

'ftp' => [
            'driver' => 'ftp',
            'host' => env('FTP_HOST'),
            'username' => env('FTP_USERNAME'),
            'password' => env('FTP_PASSWORD'),
            'root' => '/file_storage',
            'passive' => false,
            'port' => 21,
        ],

in my .env file, this is what I have

FTP_HOST=10.13.1.66
FTP_USERNAME=agriculture\foo
FTP_PASSWORD=bar

the line of code in the controller that calls the FTP array:

$file = $request->nid_file;
$doc = $individual->id.'_NIDScan_'.md5($file->getClientOriginalName()).'.'.$file->extension();
Storage::disk('ftp')->put($doc,$file);

additional information:

  • the domain name is agriculture
  • I have tried adding and removing agriculture\ in the FTP_USERNAME
  • tried adding \\ in front of the FTP_HOST IP address
  • tried setting passive to both true and false
  • changed port to 80
  • server OS is Windows.

Any help would be appreciated. Thanks.



via Chebli Mohamed

1 commentaire: