1
0
mirror of https://github.com/24eme/signaturepdf.git synced 2023-08-25 09:33:08 +02:00
signaturepdf/templates/index.html.php

57 lines
2.3 KiB
PHP
Raw Normal View History

<!doctype html>
<html lang="fr_FR">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2021-09-21 19:19:56 +02:00
2021-09-22 00:21:35 +02:00
<link href="/vendor/bootstrap.min.css?5.1.1" rel="stylesheet">
<link href="/vendor/bootstrap-icons.css?1.5.0" rel="stylesheet">
<title>Signature PDF</title>
</head>
<body>
<div class="px-4 py-5 my-5 text-center">
<h1 class="display-5 fw-bold"><i class="bi bi-vector-pen"></i> Signer un PDF</h1>
<div class="col-lg-3 mx-auto">
2021-09-21 18:22:43 +02:00
<form id="form_pdf_upload" action="/upload" method="POST" class="row g-3" enctype="multipart/form-data">
<div class="col-12">
<label for="formFileLg" class="form-label">Choisir un PDF</label>
2021-09-21 18:22:43 +02:00
<input id="input_pdf_upload" class="form-control form-control-lg" name="pdf" type="file">
</div>
<div class="col-12">
<div class="d-grid gap-2">
<button class="btn btn-light" type="submit" id="save"><i class="bi bi-upload"></i> Transmettre le PDF</button>
</div>
</div>
</form>
</div>
</div>
2021-09-21 19:19:56 +02:00
2021-09-22 00:21:35 +02:00
<script>
2021-09-21 18:22:43 +02:00
document.getElementById('input_pdf_upload').addEventListener('change', function(event) {
document.getElementById('form_pdf_upload').submit();
});
2021-11-02 01:18:13 +01:00
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(/^\#/, ''));
}
2021-09-21 18:22:43 +02:00
</script>
</body>
</html>