mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
save svg for sharing action
This commit is contained in:
parent
8d3b494309
commit
1b4c730f40
29
app.php
29
app.php
@ -172,22 +172,43 @@ $f3->route('POST /share',
|
||||
$f3->set('UPLOADS', $sharingFolder);
|
||||
mkdir($sharingFolder);
|
||||
$filename = "original.pdf";
|
||||
$tmpfile = tempnam($sharingFolder, date('YmdHis'));
|
||||
$svgFiles = "";
|
||||
|
||||
$files = Web::instance()->receive(function($file,$formFieldName){
|
||||
if(strpos(Web::instance()->mime($file['tmp_name'], true), 'application/pdf') !== 0) {
|
||||
if($formFieldName == "pdf" && strpos(Web::instance()->mime($file['tmp_name'], true), 'application/pdf') !== 0) {
|
||||
$f3->error(403);
|
||||
}
|
||||
if($formFieldName == "svg" && strpos(Web::instance()->mime($file['tmp_name'], true), 'image/svg+xml') !== 0) {
|
||||
$f3->error(403);
|
||||
}
|
||||
|
||||
return true;
|
||||
}, false, function($fileBaseName, $formFieldName) use ($filename) {
|
||||
|
||||
}, false, function($fileBaseName, $formFieldName) use ($tmpfile, $filename, &$svgFiles) {
|
||||
if($formFieldName == "pdf") {
|
||||
return $filename;
|
||||
}
|
||||
if($formFieldName == "svg") {
|
||||
$svgFiles .= " ".$tmpfile."_".$fileBaseName;
|
||||
return basename($tmpfile."_".$fileBaseName);
|
||||
}
|
||||
});
|
||||
|
||||
if(!count($files)) {
|
||||
$f3->error(403);
|
||||
}
|
||||
$f3->reroute('/signature/'.$hash."#informations");
|
||||
|
||||
if(!$svgFiles) {
|
||||
$f3->error(403);
|
||||
}
|
||||
|
||||
shell_exec(sprintf("rsvg-convert -f pdf -o %s %s", $tmpfile.'.svg.pdf', $svgFiles));
|
||||
|
||||
if(!$f3->get('DEBUG')) {
|
||||
array_map('unlink', $svgFiles);
|
||||
}
|
||||
|
||||
$f3->reroute('/signature/'.$hash);
|
||||
}
|
||||
|
||||
);
|
||||
|
@ -75,6 +75,7 @@
|
||||
<?php if(!isset($hash)): ?>
|
||||
<form id="form_sharing" action="/share" method="post" enctype="multipart/form-data">
|
||||
<input id="input_pdf_share" name="pdf" type="file" class="d-none" />
|
||||
<input id="input_svg_share" name="svg[]" type="file" class="d-none" />
|
||||
<div class="d-grid gap-2 mt-2">
|
||||
<button class="btn btn-outline-secondary" type="submit" id="save"><i class="bi bi-share"></i> Partager pour signature</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user