@@ -42,31 +42,34 @@ export default class extends Controller {
4242 this . previewImageTarget . style . display = 'none' ;
4343 this . previewImageTarget . style . backgroundImage = 'none' ;
4444 this . previewFilenameTarget . textContent = '' ;
45+ document . querySelectorAll ( '.dropzone-preview-image-container' ) . forEach ( e => e . remove ( ) ) ;
4546
4647 this . _dispatchEvent ( 'dropzone:clear' ) ;
4748 }
4849
4950 onInputChange ( event : any ) {
50- const file = event . target . files [ 0 ] ;
51- if ( typeof file === 'undefined' ) {
52- return ;
51+ for ( const fileItem in event . target . files ) {
52+ const file = event . target . files [ fileItem ] ;
53+ if ( typeof file === 'undefined' ) {
54+ return ;
55+ }
56+
57+ // Hide the input and placeholder
58+ this . inputTarget . style . display = 'none' ;
59+ this . placeholderTarget . style . display = 'none' ;
60+
61+ // Show the filename in preview
62+ this . previewFilenameTarget . textContent = file . name ;
63+ this . previewTarget . style . display = 'flex' ;
64+
65+ // If the file is an image, load it and display it as preview
66+ this . previewImageTarget . style . display = 'none' ;
67+ if ( file . type && file . type . indexOf ( 'image' ) !== - 1 ) {
68+ this . _populateImagePreview ( file ) ;
69+ }
70+
71+ this . _dispatchEvent ( 'dropzone:change' , file ) ;
5372 }
54-
55- // Hide the input and placeholder
56- this . inputTarget . style . display = 'none' ;
57- this . placeholderTarget . style . display = 'none' ;
58-
59- // Show the filename in preview
60- this . previewFilenameTarget . textContent = file . name ;
61- this . previewTarget . style . display = 'flex' ;
62-
63- // If the file is an image, load it and display it as preview
64- this . previewImageTarget . style . display = 'none' ;
65- if ( file . type && file . type . indexOf ( 'image' ) !== - 1 ) {
66- this . _populateImagePreview ( file ) ;
67- }
68-
69- this . _dispatchEvent ( 'dropzone:change' , file ) ;
7073 }
7174
7275 _populateImagePreview ( file : Blob ) {
0 commit comments