0

example image response error File not found at path enter image description here

hey can you help me?

so here I want to view the image file from the ftp server that will be responded to by JS along with the FTP server link

controller example :

$explode = explode('#',$lampiran->lampiran_gambar);
                    foreach($explode as $row){
                        if($row == null){
                          $row1[] = 'null';
                        }else{
                          $row1[] = Storage::disk('ftp')->get('/lampiranSurat' . $row);
                        }
                    }
                if($pegawai_pejabat->jenis_jabatan_id == 1){
                    return response()->json([
                        'meta' => [
                            'code' => 200,
                            'status' => 'success',
                            'message' => 'Data Ditemukan',
                        ],
                        'data_verifikasi' => $verifikasi,
                        'lampiran_gambar' => $row1,
                        'pegawai_verif'   => $pegawai_verif,
                    ]);
                }

example config filesystem :

'default' => env('FILESYSTEM_DRIVER', 'ftp')

'ftp' => [
            'driver'   => 'ftp',
            'host'     => env('FTP_HOST'),
            'username' => env('FTP_USERNAME'),
            'password' => env('FTP_PASSWORD'),
            'root'     => '/web',
        ],

config file .env :

FTP_HOST=exampleftpserver.com
FTP_USERNAME=userftp
FTP_PASSWORD=password123

so why is my ftp url not being read in storage? for image file data already in the database and already in FTP

1 Answers1

0

You're missing a / between your directory name and the filename:

Replace

$row1[] = Storage::disk('ftp')->get('/lampiranSurat' . $row);

With

$row1[] = Storage::disk('ftp')->get('/lampiranSurat/' . $row);
Peppermintology
  • 9,343
  • 3
  • 27
  • 51