mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
upload depuis l'url d'un pdf
This commit is contained in:
parent
e4947e6a20
commit
2e01794fff
@ -31,6 +31,26 @@
|
|||||||
document.getElementById('input_pdf_upload').addEventListener('change', function(event) {
|
document.getElementById('input_pdf_upload').addEventListener('change', function(event) {
|
||||||
document.getElementById('form_pdf_upload').submit();
|
document.getElementById('form_pdf_upload').submit();
|
||||||
});
|
});
|
||||||
|
async function uploadFromUrl(url) {
|
||||||
|
var response = await fetch(url);
|
||||||
|
if(response.status != 200) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var pdfBlob = await response.blob();
|
||||||
|
if(pdfBlob.type != 'application/pdf' && pdfBlob.type != 'application/octet-stream') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var dataTransfer = new DataTransfer();
|
||||||
|
var filename = url.replace(/^.*\//, '');
|
||||||
|
dataTransfer.items.add(new File([pdfBlob], filename, {
|
||||||
|
type: 'application/pdf'
|
||||||
|
}));
|
||||||
|
document.getElementById('input_pdf_upload').files = dataTransfer.files;
|
||||||
|
document.getElementById('input_pdf_upload').dispatchEvent(new Event("change"));
|
||||||
|
}
|
||||||
|
if(window.location.hash) {
|
||||||
|
uploadFromUrl(window.location.hash.replace(/^\#/, ''));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user