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

155
Views
Enviar archivo JavaScript () por correo electrónico con un clic

Tengo un script que crea un archivo a partir de datos (de un formulario o no). Tengo acceso a la URL para descargar el archivo en cualquier navegador, usando window.URL.createObjectURL. Pero me gustaría agregar un botón para enviar el archivo por correo electrónico. (Tengo un servidor y PHP). Aquí está mi código: Primero creando un archivo desde 'prueba':

 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; }

Ahora mi intento fallido:

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

Así que agradecería ayuda con 1/botón para hacer clic y enviar correo, 2/código PHP para obtener el resultado.

Muchas gracias por su ayuda, 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!