File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 25
25
</ input-container >
26
26
< input class ="btn filled blue " type ="submit " value ="Paste " />
27
27
</ form >
28
- < form method ="post " enctype ="multipart/form-data ">
28
+ < form method ="post " enctype ="multipart/form-data " id =" file_form " >
29
29
< input-container style ="flex-direction:column; gap: 1ex ">
30
30
You can also upload a file directly:
31
31
< div style ="display: flex; ">
41
41
event . target . form ?. submit ( ) ;
42
42
}
43
43
} ) ;
44
+ document . body . addEventListener ( 'paste' , ( event ) => {
45
+ if ( event . clipboardData . files . length > 0 ) {
46
+ document . querySelector ( "#file" ) . files = event . clipboardData . files
47
+ document . querySelector ( "#file_form" ) . submit ( )
48
+ }
49
+ console . log ( event . clipboardData . files [ 0 ] )
50
+ console . log ( event . clipboardData . items [ 0 ] )
51
+ if ( event . clipboardData . types . includes ( "Files" ) ) {
52
+ let image = event . clipboardData . getData ( "Files" )
53
+ console . log ( image ) ;
54
+ }
55
+ } ) ;
44
56
</ script >
45
57
{% endblock %}
You can’t perform that action at this time.
0 commit comments