回答編集履歴

3

修正 ちょい修正

2018/11/06 23:56

投稿

colling
colling

スコア798

test CHANGED
@@ -22,6 +22,10 @@
22
22
 
23
23
  img{
24
24
 
25
+ height:100px;
26
+
27
+ width:100px;
28
+
25
29
  object-fit: cover;
26
30
 
27
31
  }
@@ -42,7 +46,7 @@
42
46
 
43
47
  if (document.getElementById("upfile").files.length === 0) { return; }//ファイルが0個だったらリターンして終了
44
48
 
45
- var imgFile = document.getElementById("upfile").files[0];//ファイルをimgFileに入れる
49
+ var imgFile = document.getElementById("upfile").files[0];//先頭のファイルをimgFileに入れる
46
50
 
47
51
  imgRead.readAsDataURL(imgFile);
48
52
 
@@ -56,7 +60,7 @@
56
60
 
57
61
  <label><!--inputに対するlabelをimgの外側に置くことでimgもクリック範囲となります。-->
58
62
 
59
- <img id="uploadPreview" style="width: 100px; height: 100px;" src="https://codesign.tips/sandbox/upload2/neko.jpg">
63
+ <img id="uploadPreview" src="https://codesign.tips/sandbox/upload2/neko.jpg">
60
64
 
61
65
  <input id="upfile" type="file" name="upfile[]" accept="image/*" onchange="loadImageFile();" />
62
66
 

2

修正 ちょい修正

2018/11/06 23:56

投稿

colling
colling

スコア798

test CHANGED
@@ -21,8 +21,6 @@
21
21
  }
22
22
 
23
23
  img{
24
-
25
- /*height:100%;*/
26
24
 
27
25
  object-fit: cover;
28
26
 

1

修正 ちょい修正

2018/11/06 23:51

投稿

colling
colling

スコア798

test CHANGED
@@ -44,9 +44,9 @@
44
44
 
45
45
  if (document.getElementById("upfile").files.length === 0) { return; }//ファイルが0個だったらリターンして終了
46
46
 
47
- var oFile = document.getElementById("upfile").files[0];//先頭のファイルをoFileに入れる
47
+ var imgFile = document.getElementById("upfile").files[0];//ファイルをimgFileに入れる
48
48
 
49
- imgRead.readAsDataURL(oFile);
49
+ imgRead.readAsDataURL(imgFile);
50
50
 
51
51
  }
52
52