jeudi 5 août 2021

create link to view file in browser with laravel 5.6

i´m traying to create link for open file 'pdf' in browser with laravel 5.6. I´m using for upload files dropzone i´m uploading file ok, but when return path in my controller. My URL it´s:

file:///C:/xampp/gds/public/storage/postventapedidos/GR-11479.pdf

my app it´s in VPN with xampp server. This VPS have https, i don´t know if this it´s a problem

i have this code in my controller:

/**
     * FUNCTION TO SAVE ORDER WITH DEALER
     */
    public function saveOrderDealerNumber(Request $request){
        $adjunto = $request->file('attached');

        if(isset($adjunto)){
            $name = $adjunto->getClientOriginalName();
            $result = $adjunto->storeAs('postventapedidos', $name, 's4');

            return public_path('storage/postventapedidos/'.$name);
        }else{
            return "Error al adjuntar recibo de envío, consulte al administrador del sistema";
        }   
    }

in my blade i have this:

$("#tableFiles tbody").append(`
                    <tr class="text-center">`+
                    `<td>`+file.name+`</td>`
                    +`<td>`+file.type+`</td>`
                    +`<td>`+"{!! auth()->user()->nombre !!}"+`</td>`
                    +`<td>`+date+`</td>`
                    +`<td><a href="${response}" target="_blank"><i class="fas fa-eye text-dark fa-2x"></i></a></td>`
                    +`</tr>`);

and i can´t open this file.

In localhost, that i´m modifying this app in xampp, i can open my files ok, i don´t know would can open it.

Thanks for help me

updated

disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app/'),
        ],

        's4' => [
            'driver' => 'local',
            'root' => storage_path('app/public/'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
        ],

    ],


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire