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

228
Views
Find out files which have been downloaded

I am using the following code to retrieve a file from the server so the client can download it. Is there any way I can find out which files have been downloaded? Maybe if a text file could be stored somewhere which could keep on adding filenames as they are downloaded are accessed?

function downloadPdf(){    

//fetch the registrationId from the input#url
let registrationId = document.getElementById("url").value;        

//transform the registrationId string to lower case
registrationId = registrationId.trim().toLowerCase();

const pdfUrl = `/ooecertificate/${registrationId}.pdf`;        

//this is the statement to redirect the browser to the wanted url
//now commented because it wouldn't work here on the snippet

//window.location.href = pdfUrl;

//on its behalf I'm writing the url on console
console.log(pdfUrl); }

label.fieldLabel{
  display: block;
  margin-bottom: 1rem;
}

label.fieldDescription{
  display: block;
  margin-bottom: 1rem;   
  border: solid 1px gray;
  padding: 1em;
}

button{
  cursor: pointer;
}

<div>
  <label class="fieldDescription">
  Your registration id is your firstname+registered email id:<br>
  For example..<br>
  if your name is SAMMY DIXIT and your registered email id is SAMMY.DIXIT@GMAIL.COM<br>
  your REGISTRATION ID WILL BE: <b>sammysammy.dixit@gmail.com</b>
  </label> 

  <label class="fieldLabel">ENTER YOUR REGISTRATION ID:</label>   

  <input type="text" name="url" id="url"> 

  <button onclick="downloadPdf();">Download</button>
  
</div>

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

0

There are two ways to store the download count information:

  1. In a DATABASE

    This would be the best way since you would have access to the database from anywhere.

    The downside is that you have to implement a connection between a cloud-hosted database or a server-hosted database. Both ways you would have to pay for the service (although there are some free and limited alternatives).

  2. In a FILE

    You could store the information in a local .txt file and update it everytime a user clicks the download button but this would work only in the same computer and it's not recommended to do so

Hope this helps you

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!