mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
Share upload file original and redirect to a new route with a hash
This commit is contained in:
parent
b3c7c186a8
commit
a41155c950
39
app.php
39
app.php
@ -53,6 +53,18 @@ $f3->route('GET /signature',
|
|||||||
echo View::instance()->render('signature.html.php');
|
echo View::instance()->render('signature.html.php');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$f3->route('GET /signature/@hash',
|
||||||
|
function($f3, $param) {
|
||||||
|
$f3->set('hash', $param['hash']);
|
||||||
|
|
||||||
|
$f3->set('maxSize', min(array(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')))));
|
||||||
|
$f3->set('maxPage', ini_get('max_file_uploads') - 1);
|
||||||
|
|
||||||
|
echo View::instance()->render('signature.html.php');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$f3->route('GET /organization',
|
$f3->route('GET /organization',
|
||||||
function($f3) {
|
function($f3) {
|
||||||
$f3->set('maxSize', min(array(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')))));
|
$f3->set('maxSize', min(array(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')))));
|
||||||
@ -151,6 +163,33 @@ $f3->route('POST /sign',
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$f3->route('POST /share',
|
||||||
|
function($f3) {
|
||||||
|
$hash = substr(hash('sha512', uniqid().rand()), 0, 20);
|
||||||
|
$sharingFolder = $f3->get('STORAGE').$hash."/";
|
||||||
|
$f3->set('UPLOADS', $sharingFolder);
|
||||||
|
mkdir($sharingFolder);
|
||||||
|
$filename = "original.pdf";
|
||||||
|
|
||||||
|
$files = Web::instance()->receive(function($file,$formFieldName){
|
||||||
|
if(strpos(Web::instance()->mime($file['tmp_name'], true), 'application/pdf') !== 0) {
|
||||||
|
$f3->error(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}, false, function($fileBaseName, $formFieldName) use ($filename) {
|
||||||
|
|
||||||
|
return $filename;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!count($files)) {
|
||||||
|
$f3->error(403);
|
||||||
|
}
|
||||||
|
$f3->reroute('/signature/'.$hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
$f3->route('POST /organize',
|
$f3->route('POST /organize',
|
||||||
function($f3) {
|
function($f3) {
|
||||||
$filename = null;
|
$filename = null;
|
||||||
|
@ -28,6 +28,7 @@ var loadPDF = async function(pdfBlob, filename) {
|
|||||||
type: 'application/pdf'
|
type: 'application/pdf'
|
||||||
}));
|
}));
|
||||||
document.getElementById('input_pdf').files = dataTransfer.files;
|
document.getElementById('input_pdf').files = dataTransfer.files;
|
||||||
|
document.getElementById('input_pdf_share').files = dataTransfer.files;
|
||||||
|
|
||||||
var loadingTask = pdfjsLib.getDocument(url);
|
var loadingTask = pdfjsLib.getDocument(url);
|
||||||
loadingTask.promise.then(function(pdf) {
|
loadingTask.promise.then(function(pdf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user