Skip to content

Instantly share code, notes, and snippets.

@grekodev
Created December 14, 2019 16:59
Show Gist options
  • Save grekodev/6842ee7644bbeed33217156ca6de6fe0 to your computer and use it in GitHub Desktop.
Save grekodev/6842ee7644bbeed33217156ca6de6fe0 to your computer and use it in GitHub Desktop.
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