Reference : http://ift.tt/1qXLat4
In this project developer has taken a pdf as input and pass it to variable "input". I want to create an upload menu/dropzone so that anyone can upload their pdf and it automatically get passed to the variable "input" and text can be extracted. I am able to upload the file but don't know how to pass that pdf to the variable "input".
<body>
<form id="upload" method="post" action="upload.php" enctype="multipart/form-data">
<div id="drop">
Drop Here
<a>Browse</a>
<input id="inputx" src="./"type="file" name="upl" multiple />
</div>
<ul>
<!-- The file uploads will be shown here -->
</ul>
</form>
Now using this form a pdf will be uploaded now we have to pass it the variable "input ".
<script>
var input = document.getElementById("input");
var processor = document.getElementById("processor");
var output = document.getElementById("output");
window.addEventListener("message", function(event){
if (event.source != processor.contentWindow) return;
switch (event.data){
case "ready":
var xhr = new XMLHttpRequest;
xhr.open('GET', input.getAttribute("src"), true);
xhr.responseType = "arraybuffer";
xhr.onload = function(event) {
processor.contentWindow.postMessage(this.response, "*");
};
xhr.send();
break;
default:
output.innerHTML = event.data.replace(/\s+/g, " ");
break;
}
}, true);
</script>
</body>
Aucun commentaire:
Enregistrer un commentaire