vendredi 20 août 2021

open PDF in modal with laravel and HTTPS subdomain

I´m traying to open pdf file in modal with laravel, but always return this:

Sorry, the page you are looking for could not be found.

i don´t know that i´m doing bad.

First i´m upload my file with input type file and ajax using formData, in my controller process this file:

/**
     * FUNCTION TO SAVE ORDER WITH DEALER
     */
    public function saveOrderDealerNumber(Request $request)
    {   
        try{

            if($request->file('adjunto') != ""){

                $nombreArchivo = $request->file('adjunto')->getClientOriginalName();
                $file = $request->file('adjunto');

                $path = public_path().'/postventa';
                $uplaod = $file->move($path,$nombreArchivo);
                
                return asset('postventa/'.$nombreArchivo);
            }else{
                return "Error al subir fichero, consulte al administrador del sistema";
            }
    
        }catch(Exception $e){
            return $e->getMessage();
        }
    }

this function upload ok my file in my folder in public_path() i don´t use storage folder.

In javasript response i have this:

success: function(response){
                    var today = new Date();
                    var date = today.getDate()+"/"+"0"+(today.getMonth()+1)+"/"+today.getFullYear()+" "+
                    today.getHours() + ":" + today.getMinutes();

                    //date to insert in db
                    var dateDB = today.getFullYear()+"-"+"0"+(today.getMonth()+1)+"-"+today.getDate()+" "+today.getHours()+":"+today.getMinutes()+":"+today.getSeconds();

                    $("#adjuntoSend").val(file.name);
                    $("#usuarioSend").val('');
                    $("#fecha_horaSend").val(dateDB);
                    $("#routeAttachedSend").val(file.name);

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

                    $(".btn").on('click', function(){
                        $("#document").attr("src", response);
                    })
                },

I´m set src attr to embed tag in my modal bootstrap, this it´s result:

<embed src="https://xxxx/postventa/cliente.pdf" frameborder="0" width="100%" height="400px">

postventa it´s a folder in public.

When i´m editting my order, i have same code and also i have same error.. But in my localhost it´s ok.

my subdomain it´s in VPN in my server.

Any body have idea that i´m doing wrong?

this it´s my file My file uploaded

this it´s my route in my pc My route in my pc

Thanks for help. I´m modifying this app, all system it´s in windows server with xampp.....



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3BbvR75
via IFTTT

Aucun commentaire:

Enregistrer un commentaire