質問編集履歴
2
ソースの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -57,3 +57,65 @@
|
|
57
57
|
</script>
|
58
58
|
|
59
59
|
```
|
60
|
+
|
61
|
+
ソースコードです。
|
62
|
+
|
63
|
+
```ここに言語を入力
|
64
|
+
|
65
|
+
<div class="field">
|
66
|
+
|
67
|
+
<img alt="95b3b586 9abd 496c 8b50 1aa93fe7bad7" src="/uploads/user/picture/1/95b3b586-9abd-496c-8b50-1aa93fe7bad7.jpg" />
|
68
|
+
|
69
|
+
<label for="user_picture">画像</label>
|
70
|
+
|
71
|
+
<input id="user_picture_cache" name="user[picture_cache]" type="hidden" />
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<img id="img_prev" width=200 height=200 src="#" class="img-thumbnail hidden"/>
|
76
|
+
|
77
|
+
<input id="post_post_img" name="user[picture]" type="file" />
|
78
|
+
|
79
|
+
<script type="text/javascript">
|
80
|
+
|
81
|
+
$(function() {
|
82
|
+
|
83
|
+
function readURL(input) {
|
84
|
+
|
85
|
+
if (input.files && input.files[0]) {
|
86
|
+
|
87
|
+
var reader = new FileReader();
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
reader.onload = function (e) {
|
92
|
+
|
93
|
+
$('#img_prev').attr('src', e.target.result);
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
reader.readAsDataURL(input.files[0]);
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
$("#post_post_img").change(function(){
|
106
|
+
|
107
|
+
$('#img_prev').removeClass('hidden');
|
108
|
+
|
109
|
+
readURL(this);
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
});
|
114
|
+
|
115
|
+
</script>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
```
|
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,12 @@
|
|
7
7
|
よろしくお願いいたします。
|
8
8
|
|
9
9
|
```rails
|
10
|
+
|
11
|
+
<%= image_tag @user.picture.url if @user.picture? %>
|
12
|
+
|
13
|
+
<%= f.label :picture, '画像' %>
|
14
|
+
|
15
|
+
<%= f.hidden_field :picture_cache %>
|
10
16
|
|
11
17
|
<img id="img_prev" width=200 height=200 src="#" class="img-thumbnail hidden"/>
|
12
18
|
|