Created
December 14, 2019 16:59
-
-
Save grekodev/6842ee7644bbeed33217156ca6de6fe0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP | |
======= | |
public function readImage() | |
{ | |
header('Content-type: image/jpeg'); | |
echo file_get_contents("http://app1.susalud.gob.pe/registro/Home/GeneraCaptcha?accion=image"); | |
} | |
=================================================================================================== | |
JS | |
======= | |
function getCaptcha(url_image) { | |
fetch(url_image) | |
.then(response => response.blob()) | |
.then(images => { | |
var reader = new window.FileReader(); | |
reader.readAsDataURL(images); | |
reader.onload = function () { | |
var imageDataUrl = reader.result; | |
let imageElement = document.getElementById('image'); | |
imageElement.setAttribute("src", imageDataUrl); | |
} | |
}) | |
} | |
=================================================================================================== | |
HTML | |
======= | |
<img id="image" alt=""> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment