Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
Javascript Filereader pdf cargar con imagen

Tengo un problema con la carga de mi archivo de javascript a laravel y lo muestro para su uso posterior, a continuación se muestra mi código para cargar y guardar en db y recuperarlo más tarde y mostrarlo

 $(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); } }

en el botón Enviar en modal, este código se ejecutará y se guardará en db usando el objeto base64_encode y se almacenará como 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; }

cuando un usuario hace clic en el archivo cargado, se abre una nueva ventana para mostrar el archivo. Todo funciona bien con esto, siempre que el pdf contenga datos de texto, pero cuando el pdf es completamente una imagen, no mostrará nada, se agradecerá cualquier ayuda al respecto.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!