pdufour commited on
Commit
f18b0ff
·
verified ·
1 Parent(s): ab198d8

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +11 -8
index.js CHANGED
@@ -335,16 +335,19 @@ fileUpload.addEventListener('change', async function(e) {
335
  const file = e.target.files[0];
336
  if (!file) return;
337
 
338
- const url = e2.target.result;
339
-
340
- const image = await RawImage.fromURL(url);
341
- const ar = image.width / image.height;
342
- const [cw, ch] = (ar > 1) ? [640, 640 / ar] : [640 * ar, 640];
343
- imageContainer.style.width = `${cw}px`;
344
- imageContainer.style.height = `${ch}px`;
345
- imageContainer.style.backgroundImage = `url(${url})`;
346
 
347
  const reader = new FileReader();
 
 
 
 
 
 
 
 
 
348
  // reader.onload = e2 => parse(e2.target.result, '');
 
 
349
  reader.readAsDataURL(file);
350
  });
 
335
  const file = e.target.files[0];
336
  if (!file) return;
337
 
 
 
 
 
 
 
 
 
338
 
339
  const reader = new FileReader();
340
+ reader.onload = (e2) => {
341
+ const url = e2.target.result;
342
+
343
+ const image = await RawImage.fromURL(url);
344
+ const ar = image.width / image.height;
345
+ const [cw, ch] = (ar > 1) ? [640, 640 / ar] : [640 * ar, 640];
346
+ imageContainer.style.width = `${cw}px`;
347
+ imageContainer.style.height = `${ch}px`;
348
+ imageContainer.style.backgroundImage = `url(${url})`;
349
  // reader.onload = e2 => parse(e2.target.result, '');
350
+
351
+ }
352
  reader.readAsDataURL(file);
353
  });