@@ -179,7 +179,11 @@ public function saveAllegati($name = null)
179179 if (!empty ($ allegato ['FormatoAttachment ' ])) {
180180 $ extension = '. ' .strtolower ((string ) $ allegato ['FormatoAttachment ' ]);
181181 }
182-
182+
183+ if (strtolower ($ extension ) == '.html ' || strtolower ($ extension ) == '.htm ' ) {
184+ $ extension = '.pdf ' ;
185+ }
186+
183187 if (preg_match ('/\./ ' , (string ) $ allegato ['NomeAttachment ' ])) {
184188 $ original = $ allegato ['NomeAttachment ' ];
185189 } else {
@@ -195,10 +199,21 @@ public function saveAllegati($name = null)
195199 }
196200
197201 // Registrazione XML come allegato
198- \Uploads::upload (file_get_contents ($ this ->file ), array_merge ($ info , [
199- 'name ' => tr ('Fattura Elettronica ' ),
200- 'original_name ' => basename ($ this ->file ),
201- ]));
202+ $ file_content = file_get_contents ($ this ->file );
203+
204+ $ original_name = basename ($ this ->file );
205+ if (empty (pathinfo ($ original_name , PATHINFO_EXTENSION ))) {
206+ $ original_name .= '.xml ' ;
207+ }
208+
209+ try {
210+ \Uploads::upload ($ file_content , array_merge ($ info , [
211+ 'name ' => tr ('Fattura Elettronica ' ),
212+ 'original_name ' => $ original_name ,
213+ ]));
214+ } catch (\UnexpectedValueException $ e ) {
215+ error_log ('Errore durante il caricamento del file XML: ' . $ e ->getMessage ());
216+ }
202217 }
203218
204219 public function findAnagrafica ($ tipo = null )
0 commit comments