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

227
Views
How to convert the selected file to blob format?

I have simple input-file field.

<input  type="file"
       id="openselect"
       name="files[]"
       (change)="fileSelect($event)">

It has related function that tries to convert selected file to BLOB format.

openselect.addEventListener("change", fileSelect, false);
function fileSelect(event) {
  const file = event.target['files'][0];
  const fileReader = new FileReader();
  fileReader.readAsText(file);
  console.log(fileReader.result)    // null
  console.log('iamge as blob: ', new Blob([fileReader.result]))        // meta info
}

As a result, console only displays file meta info, but doesnt display BLOB-string.

Please help me convert selected file to a BLOB-string.

Here is a live example.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Take a look at Mozilla's FileReader Documentation (https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result):

This example presents a function, read(), which reads a file from a file input. It works by creating a FileReader object and creating a listener for load events such that when then file is read, the result is obtained and passed to the callback function provided to read().

Solution: Live Example

Another Question that might help you HTML5 FileReader how to return result?

about 4 years ago · Juan Pablo Isaza Report
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!