• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

172
Views
js error: "'createObjectURL' en 'URL': error en la resolución de sobrecarga".

Trato de mostrar una imagen en una página php en js, sabiendo que mi imagen a través de un archivo de entrada. aquí está mi código:

 <script> function image(){ var x = document.getElementById("image_uploads"); var test = URL.createObjectURL(x); //document.getElementById("img").src = URL.createObjectURL(x); } </script> <body> <div class="frItem31"> <form name="saisie" action="" method="post"> Image 1 :<input type="file" id="image_uploads" class="image_uploads" name="image_uploads" accept="image/*"/> <br> <img id="img" class="img"> <br> <input type="button" id="calcVitesse" class="calcVitesse" value="calculer la vitesse" onclick="image()"> </form> </div> </body>

aquí está el error que obtengo:

Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed. at image (image.php:20:32) at HTMLInputElement.onclick (image.php:80:125) image @ image.php:20 onclick @ image.php:80

Usted me podría ayudar por favor !?!

ES

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

está pasando un elemento HTML en lugar de un archivo. Para obtener el archivo, use la propiedad .files , que se comporta como un Array , para que pueda iterarlo. consulte: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#getting_information_on_selected_files

prueba esto:

 function image() { var x = document.getElementById("image_uploads"); if (x.files.length) { var test = URL.createObjectURL(x.files[0]); } }
almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error