diff 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
line wrap: on
line diff
--- a/src/test/upload.html	Mon Aug 01 22:50:16 2022 -0600
+++ b/src/test/upload.html	Tue Aug 02 20:46:02 2022 -0600
@@ -7,11 +7,11 @@
 		</style>
 		<script src="/site.js"></script>
 		<script>
-			function gotFile(input) {
-				let file = input.files[0];
-				//console.log(file);
-				//console.log(file instanceof File);
-				ajax("upload.js",file);
+			function uploaded(url,filename) {
+				console.log(url);
+				let a = document.querySelector('a');
+				a.textContent = filename;
+				a.setAttribute('href',url);
 			}
 		</script>
 	</head>
@@ -19,10 +19,8 @@
 		<div content>
 			<p>top</p>
 			<p>
-				<label clickable
-					><input type=file xaccept="image/*" onchange="gotFile(this)"
-					><span inline_button>Upload File</span>
-				</label>
+				<input type=file xaccept="image/*" onchange="upload(this,uploaded)">
+				<button onclick="fileButtonClick(this)">Upload File</button>
 			</p>
 			<p><a></a></p>
 			<p>bottom</p>