Good friends I'm trying to copy a screenshot and paste it into my program I found a code on the following page link which does what I want is copied and pasted the screenshot, but I do not know how to manage to upload the image to the server is to send it either by a traditional form or by ajax, in simple words I do not know how to take the image and send it. This is the code that allows me to paste the screenshot taken with the imprpant key in the project.
<script>
window.addEventListener("paste", processEvent);
function processEvent(e) {
for (var i = 0; i < e.clipboardData.items.length; i++) {
// get the clipboard item
// obtengo el clipboard item
var clipboardItem = e.clipboardData.items[0];
var type = clipboardItem.type;
// verifico si es una imagen
if (type.indexOf("image") != -1) {
// obtengo el contenido de la imagen BLOB
var blob = clipboardItem.getAsFile();
console.log("blob", blob);
// creo un la URL del objeto
var blobUrl = URL.createObjectURL(blob);
console.log("blobUrl", blobUrl);
// agrego la captura a mi imagen
document.getElementsByTagName("img")[0].setAttribute("src", blobUrl);
} else {
console.log("No soportado " + type);
}
}
}
</script>
and the html where the image is pasted
<body>
<header><h1>Obteniendo una captura de pantalla del portapapeles (clipboard) con JavaScript</h1></header>
<section>
<img>
<h3>(Pega la imagen con Ctrl + V)</h3>
</section>
</body>
What I want is to take the image and upload it to a directory on my server and the path in mysql, although I know how that process is done I do not know how to get the values of the image.Greetings