Fix importazione allegati FE senza estensione

This commit is contained in:
Dasc3er 2021-04-02 14:58:34 +02:00
parent 47ed1d75fd
commit b95f1fed26
2 changed files with 6 additions and 5 deletions

View File

@ -179,7 +179,7 @@ class FatturaElettronica
foreach ($allegati as $allegato) {
$content = base64_decode($allegato['Attachment']);
$extension = '';
$extension = '.pdf';
if (!empty($allegato['FormatoAttachment'])) {
$extension = '.'.strtolower($allegato['FormatoAttachment']);
}

View File

@ -104,16 +104,17 @@ class Upload extends Model
// Creazione del file fisico
directory($directory);
$file = slashes($directory.DIRECTORY_SEPARATOR.$filename);
if (
(is_array($source) && is_uploaded_file($source['tmp_name']) && !move_uploaded_file($source['tmp_name'], $directory.'/'.$filename)) ||
(is_string($source) && is_file($source) && !copy($source, $directory.'/'.$filename)) ||
(is_string($source) && !is_file($source) && file_put_contents($directory.'/'.$filename, $source) === false)
(is_array($source) && is_uploaded_file($source['tmp_name']) && !move_uploaded_file($source['tmp_name'], $file)) ||
(is_string($source) && is_file($source) && !copy($source, $file)) ||
(is_string($source) && !is_file($source) && file_put_contents($file, $source) === false)
) {
throw new UnexpectedValueException("Errore durante il salvataggio dell'allegato");
}
// Aggiornamento dimensione fisica e responsabile del caricamento
$model->size = FileSystem::fileSize($directory.'/'.$filename);
$model->size = FileSystem::fileSize($file);
$model->user()->associate(auth()->getUser());
// Rimozione estensione dal nome visibile