Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
129 righe
5.7 KiB
129 righe
5.7 KiB
<? |
|
if (!empty($onSuccessScript)) { |
|
if (empty($uploaderID)) { |
|
$uploaderID = generateStrongPassword(9,false,'lud'); |
|
} |
|
$uploaderVarID = "_".preg_replace('/[^\w]/', '_', $uploaderID); |
|
if (!isset($options)) { |
|
$options = []; |
|
} |
|
if (!isset($options["allowedTypes"])) { |
|
$options["allowedTypes"] = filesManager::acceptedFilesExtensions(); |
|
} |
|
if (is_array($options["allowedTypes"])) { |
|
$allowedTypesForLabel = implode(" ",$options["allowedTypes"]); |
|
$options["allowedTypes"] = filesManager::extensionsArrayToRegex($options["allowedTypes"]); |
|
} |
|
|
|
?> |
|
<div class="card card-body my-2"> |
|
<div class="col-12 dropper-parent"> |
|
<div id="<?= $uploaderVarID ?>-dropzone-attachment" class="dropper-dropzone fileinput-button" style="height:auto"> |
|
<input id="<?= $uploaderVarID ?>-input-fileupload" <? if (!isset($options["maxNumberOfFiles"]) || $options["maxNumberOfFiles"] > 1) { ?>multiple<? } ?> class="attachment-fileupload" type='file' name='files'> |
|
<div class="div-as-table"> |
|
<div class="cell text-break"> |
|
<? if (isset($options["maxNumberOfFiles"]) && $options["maxNumberOfFiles"] === 1) { ?> |
|
<strong> |
|
<span class="far fa-folder fa-2x"></span><br> |
|
<?= __("Scegli file") ?>... |
|
</strong> |
|
<? } else { ?> |
|
<span class="far fa-folder fa-2x"></span> |
|
<h4><?= __("Trascina i files in questa area oppure clicca per selezionare un file...") ?></h4> |
|
<? } ?> |
|
</div> |
|
<? if (!empty($options["maxFileSize"])) { ?> |
|
<div class="text-center"> |
|
<strong><?= __("Dimensione massima").":" . human_filesize($options["maxFileSize"]) ?></strong> |
|
</div> |
|
<? } ?> |
|
<? if (!empty($allowedTypesForLabel)) { ?> |
|
<div class="text-center"> |
|
<small><?= __("Estensioni accettate")."<br>" .$allowedTypesForLabel ?></small> |
|
</div> |
|
<? } ?> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="col-12 my-2"> |
|
<div id="<?= $uploaderVarID ?>-progress" class="progress"> |
|
<div class="progress-bar bg-info" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div> |
|
<input type="hidden" rel="S;0;0;A" value="OK" id="<?= $uploaderVarID ?>-upload-end" title="<?= __("Fine caricamento allegati") ?>"> |
|
</div> |
|
</div> |
|
</div> |
|
<script type="text/javascript"> |
|
$(document).bind('drop dragover', function (e) { e.preventDefault(); }); |
|
jQuery(document).ready(function($) { |
|
if(!$.support.fileInput) { |
|
Swal({ |
|
title: '<strong>Il tuo browser non supporta la procedura di <u>upload dei file</u>.</strong>', |
|
type: 'error', |
|
html: |
|
'<b>Ti consigliamo di aggiornare il browser in uso o di utilizzarne uno dei seguenti:</b> ' + |
|
'<a href="http://www.google.it/intl/it/chrome/browser/">Google Chrome</a> oppure ' + |
|
'<a href="http://www.mozilla.org/it/firefox/new/">Mozilla Firefox</a> ' |
|
}); |
|
} |
|
$('#<?= $uploaderVarID ?>-input-fileupload').fileupload({ |
|
maxChunkSize: 3*1024*1024, |
|
<? if (!empty($options["maxFileSize"])) { ?> |
|
maxFileSize: <?= $options["maxFileSize"] ?>, |
|
<? } ?> |
|
<? if (!empty($options["maxNumberOfFiles"])) { ?> |
|
maxNumberOfFiles: <?= $options["maxNumberOfFiles"] ?>, |
|
<? } ?> |
|
url: '/allegati/servers/blueimp.php', |
|
dataType: 'json', |
|
add: function (e, data) { |
|
$.each(data.files, function (index, file) { |
|
file.name = sanitize_string(window.htmlentities.decode(file.name)); |
|
if (!(<?= $options["allowedTypes"] ?>).test(file.name)) { |
|
swal({ |
|
title: "Attenzione!", |
|
html: "Questo tipo di file non è valido! Il file non ha un'estenzione valida!", |
|
type: "warning", |
|
confirmButtonText: "Riprova", |
|
confirmButtonClass: 'btn btn-outline-warning', |
|
}); |
|
return false; |
|
} else { |
|
$('#<?= $uploaderVarID ?>-upload-end').val(''); |
|
data.submit(); |
|
} |
|
}); |
|
}, |
|
done: function (e, data) { |
|
$.each(data.result.files, function (index, file) { |
|
if('error' in file) { |
|
swal({ |
|
title: "Attenzione!", |
|
html: "Si è verificato un errore nel caricamento del file. Si prega di riprovare!", |
|
type: "warning", |
|
confirmButtonText: "Ok", |
|
confirmButtonClass: 'btn btn-outline-warning', |
|
}); |
|
} else { |
|
<?= $onSuccessScript ?> |
|
<? if (isset($options["maxNumberOfFiles"]) && $options["maxNumberOfFiles"] === 1) { ?> |
|
$("#<?= $uploaderVarID ?>-dropzone-attachment").find(".cell").html("<strong class='text-primary'><span class='far fa-file'></span> "+file.name+"</strong>"); |
|
<? } ?> |
|
} |
|
}); |
|
}, |
|
progressall: function (e, data) { |
|
var progress = parseInt(data.loaded / data.total * 100, 10); |
|
$('#<?= $uploaderVarID ?>-progress .progress-bar').css('width', progress + '%'); |
|
if (progress >= 100) { |
|
$('#<?= $uploaderVarID ?>-upload-end').val('OK'); |
|
} else { |
|
$('#<?= $uploaderVarID ?>-upload-end').val(''); |
|
} |
|
} |
|
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled'); |
|
}); |
|
</script> |
|
|
|
<? |
|
} |
|
?>
|