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

151
Views
Send JavaScript File() by email onclick

I have a script making a file from data (from a form or not). I have access to the URL to download the file in any browser, using window.URL.createObjectURL. But I would like to add a button to send the file by email. (I have a server and PHP). Here is my code: First creating File from 'test':

function makeFile(text) {
  var test =
    "Here is my " + text;
var data = new File([test], { type: "text/plain" });
  if (myFile !== null) {
    window.URL.revokeObjectURL(myFile);
  }

  myFile = window.URL.createObjectURL(data);

  return myFile;
}

Now my unsuccessful attempt:

<form action="emailthijob.php" method="post">
<a class="download hide" id="sendbyemail" onclick="myFile.submit()";>⇧ Email</a>
</form>

So I would appreciate help with 1/button to click and send mail, 2/ PHP code to actually get the result.

Thank you very much for your help, Best, --Fred

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!