Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
Javascript Filereader pdf upload with image

I am having an issue with my file upload from javascript to laravel and displaying it for later use, below is my code to upload and save to db and retrieve later and display it

$(document).on("change", "#facesheet", function() {
            handleFileSelect($(this));
        });

        function handleFileSelect(evt) {
            var files = $(evt)[0].files; // FileList object

            for (var i = 0, f; f = files[i]; i++) {
                var reader = new FileReader();

                reader.onload = (function(theFile) {
                    return function(e) {
                        var fileString = e.target.result;

                        $("#divFileUpload").removeData("file");
                        $("#divFileUpload").removeData(
                            "filename");
                        $("#divFileUpload").removeData("extension");

                        $("#divFileUpload").data("file", fileString);
                        $("#divFileUpload").data(
                            "filename", theFile.name);
                        $("#divFileUpload").data("extension", theFile
                            .name.split('.').pop().toLowerCase());
                    };
                })(f);

                reader.readAsDataURL(f);
            }
        }

on submit button in modal, this code will execute and saves to db using base64_encode object and stores as blob

function uploadpdf() {
            var $formdata = {
                'data': $("#divFileUpload").data("file"),
                'filename': $("#divFileUpload").data("filename"),
                'type': $("#divFileUpload").data("extension"),
                'Number': $("#hdnNumber").val()
            };

            $.ajax({
                url: '/upload',
                type: 'POST',
                data: $formdata,
                success: function(response) {
                    alert("Uploaded successfully");
                    window.location.reload();
                }
            });
            return false;
        }

when a user click on the uploaded file it opens a new window to display the file. Everything works fine with this as long as pdf contains text data but when pdf is completely an image then it wont display anything, any help will be appreciated on this.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda