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

234
Views
How to create a custom link to a uploaded local file object?

I Want to generate a link for my local woff file. With help of createobjectURL function, A link is created, however, the penalty is in the way of a blob. The URL lifetime is tied to the document in the window on which it was created. The URL runs only on my browser, and when I close relevant tab, the file disappears. So, I'm trying to find a way using js function which creates a perm link to uploaded local file. Currently I used .

   

 <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <title>URL.createObjectURL example</title>
    </head>
    <body>
      <input type="file">
      <file>
      <p class="p">The URL of file is : </p>
    </body>
    <script>
        var Element = document.querySelector('input');
        var file = document.querySelector('file');
        Element.addEventListener('change', function() {
          var url = URL.createObjectURL(Element.files[0]);
          file.src = url;
          console.log(url);
          var d=document.querySelector(".p");
          d.textContent+=url;
    });
    </script>
    </html>
It creates blob:https://www.example.com/123 however I require https://www.example.com/123. I also tried Base 64 encoding. It works but the file size, and speed becomes a drawback even when it is compressed.

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

0

You're asking for one thing but giving an example of another here.

I Want to generate a permanent link for my local woff file.

You can't generate a URL to file://etc/etc since:

  • Browsers don't expose information about the user's file system to JS
  • If you could get a URL like that, then the browser wouldn't let the webpage link to it.

Access to local files is heavily restricted.


I require https://www.example.com/123

If you want the file to be available on your website: actually upload it to the website! Right now, the file only exists on the user's disk and in the memory being accessed by their browser.

You have to send the data to a server (e.g. with an Ajax POST request) where you have a webservice which reads the request, extracts the file from it, stores the file somewhere, gives it a URL, and then sends the URL back to the browser.

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!