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

181
Views
¿Cómo copiar un archivo y luego cambiarle el nombre según el campo de entrada haciendo clic en un botón?

¡Buen día expertos!

Quiero copiar un archivo y cambiarle el nombre según el valor de entrada haciendo clic en el botón. MI código no funciona. No se copia ni se cambia el nombre de ningún archivo. Aquí está mi código:

 <?php error_reporting(0); if($_POST['action'] == 'call_this') { echo Success!; }; $file = 'data.php'; $newfile = '$_GET['subject'].php'; echo copy($file, $newfile); ?> <form action="<?php echo $newfile ?>" method="get"> <input type="text" name="subject" required> <button type="submit"><a href="" onclick="change()">Change</a></button> </form> <script> function change() { $.ajax({ type: "POST", url: 'data.php', data:{action:'call_this'}, success:function(html) { alert(html); } }); } </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

creo que esto es lo que buscas:

 <html> <body> <form method="post" action="copy.php"> <input type="text" placeholder="new name" name="newFileName"/> <input type="submit" value="Change"/> </form> </body> </html>

copiar.php:

 <?php $file = 'sample.txt'; $newfile = $_POST["newFileName"].'.txt'; if (!copy($file, $newfile)) { echo "failed to copy"; }else { echo "copy with new name"; } ?>
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!