comparison src/test/upload.html @ 34:c8d47981c74f

upload using ajax
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 02 Aug 2022 20:46:02 -0600
parents 4fdc4ec0050b
children 1ce75c5ab0f7
comparison
equal deleted inserted replaced
33:4fdc4ec0050b 34:c8d47981c74f
5 <style> 5 <style>
6 @import "/site.css"; 6 @import "/site.css";
7 </style> 7 </style>
8 <script src="/site.js"></script> 8 <script src="/site.js"></script>
9 <script> 9 <script>
10 function gotFile(input) { 10 function uploaded(url,filename) {
11 let file = input.files[0]; 11 console.log(url);
12 //console.log(file); 12 let a = document.querySelector('a');
13 //console.log(file instanceof File); 13 a.textContent = filename;
14 ajax("upload.js",file); 14 a.setAttribute('href',url);
15 } 15 }
16 </script> 16 </script>
17 </head> 17 </head>
18 <body> 18 <body>
19 <div content> 19 <div content>
20 <p>top</p> 20 <p>top</p>
21 <p> 21 <p>
22 <label clickable 22 <input type=file xaccept="image/*" onchange="upload(this,uploaded)">
23 ><input type=file xaccept="image/*" onchange="gotFile(this)" 23 <button onclick="fileButtonClick(this)">Upload File</button>
24 ><span inline_button>Upload File</span>
25 </label>
26 </p> 24 </p>
27 <p><a></a></p> 25 <p><a></a></p>
28 <p>bottom</p> 26 <p>bottom</p>
29 </div> 27 </div>
30 </body> 28 </body>