質問編集履歴

4

実行ソースを変更

2017/06/01 04:43

投稿

oyashiro
oyashiro

スコア37

test CHANGED
File without changes
test CHANGED
@@ -10,340 +10,402 @@
10
10
 
11
11
  ```
12
12
 
13
+ public function edit(Application $app, Request $request, $id = null)
14
+
15
+ {
16
+
17
+
18
+
19
+ 省略
20
+
21
+
22
+
23
+ // ファイルの登録
24
+
13
- $files = array();
25
+ $images = array();
14
-
26
+
15
- if (count($images) > 0) {
27
+ $ProductImages = $Product->getProductImage();
16
-
28
+
17
- foreach ($images as $img) {
29
+ foreach ($ProductImages as $ProductImage) {
18
-
19
- foreach ($img as $image) {
30
+
20
-
21
- //ファイルフォーマット検証
22
-
23
- $mimeType = $image->getMimeType();
31
+ $images[] = $ProductImage->getFileName();
32
+
24
-
33
+ }
34
+
35
+ $form['images']->setData($images);
36
+
37
+
38
+
39
+ $categories = array();
40
+
41
+ $ProductCategories = $Product->getProductCategories();
42
+
43
+ foreach ($ProductCategories as $ProductCategory) {
44
+
45
+ /* @var $ProductCategory \Eccube\Entity\ProductCategory */
46
+
47
+ $categories[] = $ProductCategory->getCategory();
48
+
49
+ }
50
+
51
+ $form['Category']->setData($categories);
52
+
53
+
54
+
55
+ $Tags = array();
56
+
57
+ $ProductTags = $Product->getProductTag();
58
+
59
+ foreach ($ProductTags as $ProductTag) {
60
+
61
+ $Tags[] = $ProductTag->getTag();
62
+
63
+ }
64
+
65
+ $form['Tag']->setData($Tags);
66
+
67
+
68
+
69
+ if ('POST' === $request->getMethod()) {
70
+
71
+ $form->handleRequest($request);
72
+
73
+ if ($form->isValid()) {
74
+
75
+ log_info('商品登録開始', array($id));
76
+
77
+ $Product = $form->getData();
78
+
79
+
80
+
81
+ if (!$has_class) {
82
+
83
+ $ProductClass = $form['class']->getData();
84
+
85
+
86
+
87
+ // 個別消費税
88
+
89
+ $BaseInfo = $app['eccube.repository.base_info']->get();
90
+
91
+ if ($BaseInfo->getOptionProductTaxRule() == Constant::ENABLED) {
92
+
25
- if (0 !== strpos($mimeType, 'image')) {
93
+ if ($ProductClass->getTaxRate() !== null) {
94
+
26
-
95
+ if ($ProductClass->getTaxRule()) {
96
+
97
+ if ($ProductClass->getTaxRule()->getDelFlg() == Constant::ENABLED) {
98
+
99
+ $ProductClass->getTaxRule()->setDelFlg(Constant::DISABLED);
100
+
101
+ }
102
+
103
+
104
+
105
+ $ProductClass->getTaxRule()->setTaxRate($ProductClass->getTaxRate());
106
+
107
+ } else {
108
+
27
- throw new UnsupportedMediaTypeHttpException('ファイル形式が不正です');
109
+ $taxrule = $app['eccube.repository.tax_rule']->newTaxRule();
110
+
111
+ $taxrule->setTaxRate($ProductClass->getTaxRate());
112
+
113
+ $taxrule->setApplyDate(new \DateTime());
114
+
115
+ $taxrule->setProduct($Product);
116
+
117
+ $taxrule->setProductClass($ProductClass);
118
+
119
+ $ProductClass->setTaxRule($taxrule);
120
+
121
+ }
122
+
123
+ } else {
124
+
125
+ if ($ProductClass->getTaxRule()) {
126
+
127
+ $ProductClass->getTaxRule()->setDelFlg(Constant::ENABLED);
128
+
129
+ }
130
+
131
+ }
28
132
 
29
133
  }
30
134
 
31
-
135
+ $app['orm.em']->persist($ProductClass);
136
+
137
+
138
+
32
-
139
+ // 在庫情報を作成
140
+
33
- $extension = $image->getClientOriginalExtension();
141
+ if (!$ProductClass->getStockUnlimited()) {
34
-
35
- $filename = date('mdHis') . uniqid('_') . '.' . $extension;
142
+
36
-
37
- $image->move($app['config']['image_temp_realdir'], $filename);
143
+ $ProductStock->setStock($ProductClass->getStock());
144
+
38
-
145
+ } else {
146
+
39
- $files[] = $filename;
147
+ // 在庫無制限時はnullを設定
148
+
40
-
149
+ $ProductStock->setStock(null);
150
+
41
- }
151
+ }
152
+
153
+ $app['orm.em']->persist($ProductStock);
154
+
155
+ }
156
+
157
+
158
+
159
+
160
+
161
+ 省略
162
+
163
+
164
+
165
+
166
+
167
+ // 画像の登録
168
+
169
+ $add_images = $form->get('add_images')->getData();
170
+
171
+ foreach ($add_images as $add_image) {
172
+
173
+ $ProductImage = new \Eccube\Entity\ProductImage();
174
+
175
+ $ProductImage
176
+
177
+ ->setFileName($add_image)
178
+
179
+ ->setProduct($Product)
180
+
181
+ ->setRank(1);
182
+
183
+ $Product->addProductImage($ProductImage);
184
+
185
+ $app['orm.em']->persist($ProductImage);
186
+
187
+
188
+
189
+ // 移動
190
+
191
+ $file = new File($app['config']['image_temp_realdir'] . '/' . $add_image);
192
+
193
+ $file->move($app['config']['image_save_realdir']);
194
+
195
+ }
196
+
197
+
198
+
199
+ // 画像の削除
200
+
201
+ $delete_images = $form->get('delete_images')->getData();
202
+
203
+ foreach ($delete_images as $delete_image) {
204
+
205
+ $ProductImage = $app['eccube.repository.product_image']
206
+
207
+ ->findOneBy(array('file_name' => $delete_image));
208
+
209
+
210
+
211
+ // 追加してすぐに削除した画像は、Entityに追加されない
212
+
213
+ if ($ProductImage instanceof \Eccube\Entity\ProductImage) {
214
+
215
+ $Product->removeProductImage($ProductImage);
216
+
217
+ $app['orm.em']->remove($ProductImage);
218
+
219
+
220
+
221
+ }
222
+
223
+ $app['orm.em']->persist($Product);
224
+
225
+
226
+
227
+ // 削除
228
+
229
+ $fs = new Filesystem();
230
+
231
+ $fs->remove($app['config']['image_save_realdir'] . '/' . $delete_image);
232
+
233
+ }
234
+
235
+ $app['orm.em']->persist($Product);
236
+
237
+ $app['orm.em']->flush();
238
+
239
+
240
+
241
+
242
+
243
+ $ranks = $request->get('rank_images');
244
+
245
+ if ($ranks) {
246
+
247
+ foreach ($ranks as $rank) {
248
+
249
+ list($filename, $rank_val) = explode('//', $rank);
250
+
251
+ $ProductImage = $app['eccube.repository.product_image']
252
+
253
+ ->findOneBy(array(
254
+
255
+ 'file_name' => $filename,
256
+
257
+ 'Product' => $Product,
258
+
259
+ ));
260
+
261
+ $ProductImage->setRank($rank_val);
262
+
263
+ $app['orm.em']->persist($ProductImage);
264
+
265
+ }
266
+
267
+ }
268
+
269
+ $app['orm.em']->flush();
270
+
271
+
272
+
273
+ // 商品タグの登録
274
+
275
+ // 商品タグを一度クリア
276
+
277
+ $ProductTags = $Product->getProductTag();
278
+
279
+ foreach ($ProductTags as $ProductTag) {
280
+
281
+ $Product->removeProductTag($ProductTag);
282
+
283
+ $app['orm.em']->remove($ProductTag);
284
+
285
+ }
286
+
287
+
288
+
289
+ // 商品タグの登録
290
+
291
+ $Tags = $form->get('Tag')->getData();
292
+
293
+ foreach ($Tags as $Tag) {
294
+
295
+ $ProductTag = new ProductTag();
296
+
297
+ $ProductTag
298
+
299
+ ->setProduct($Product)
300
+
301
+ ->setTag($Tag);
302
+
303
+ $Product->addProductTag($ProductTag);
304
+
305
+ $app['orm.em']->persist($ProductTag);
306
+
307
+ }
308
+
309
+ $app['orm.em']->flush();
310
+
311
+
312
+
313
+ log_info('商品登録完了', array($id));
314
+
315
+
316
+
317
+ $event = new EventArgs(
318
+
319
+ array(
320
+
321
+ 'form' => $form,
322
+
323
+ 'Product' => $Product,
324
+
325
+ ),
326
+
327
+ $request
328
+
329
+ );
330
+
331
+ $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_EDIT_COMPLETE, $event);
332
+
333
+
334
+
335
+ $app->addSuccess('admin.register.complete', 'admin');
336
+
337
+
338
+
339
+ return $app->redirect($app->url('admin_product_product_edit', array('id' => $Product->getId())));
340
+
341
+ } else {
342
+
343
+ log_info('商品登録チェックエラー', array($id));
344
+
345
+ $app->addError('admin.register.failed', 'admin');
42
346
 
43
347
  }
44
348
 
45
349
  }
46
350
 
351
+
352
+
353
+ // 検索結果の保持
354
+
355
+ $builder = $app['form.factory']
356
+
357
+ ->createBuilder('admin_search_product');
358
+
359
+
360
+
361
+ $event = new EventArgs(
362
+
363
+ array(
364
+
365
+ 'builder' => $builder,
366
+
367
+ 'Product' => $Product,
368
+
369
+ ),
370
+
371
+ $request
372
+
373
+ );
374
+
375
+ $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_EDIT_SEARCH, $event);
376
+
377
+
378
+
379
+ $searchForm = $builder->getForm();
380
+
381
+
382
+
383
+ if ('POST' === $request->getMethod()) {
384
+
385
+ $searchForm->handleRequest($request);
386
+
387
+ }
388
+
389
+
390
+
391
+ return $app->render('Product/product.twig', array(
392
+
393
+ 'Product' => $Product,
394
+
395
+ 'form' => $form->createView(),
396
+
397
+ 'searchForm' => $searchForm->createView(),
398
+
399
+ 'has_class' => $has_class,
400
+
401
+ 'id' => $id,
402
+
403
+ ));
404
+
405
+ }
406
+
407
+
408
+
409
+
410
+
47
411
  ```
48
-
49
-
50
-
51
-
52
-
53
- Javascript追記
54
-
55
- ```
56
-
57
- <script>
58
-
59
- $(function() {
60
-
61
- $("#thumb").sortable({
62
-
63
- cursor: 'move',
64
-
65
- opacity: 0.7,
66
-
67
- placeholder: 'ui-state-highlight',
68
-
69
- update: function (event, ui) {
70
-
71
- updateRank();
72
-
73
- }
74
-
75
- });
76
-
77
- {% if has_class == false %}
78
-
79
- if ($("#{{ form.class.stock_unlimited.vars.id }}").prop("checked")) {
80
-
81
- $("#{{ form.class.stock.vars.id }}").attr("disabled", "disabled").val('');
82
-
83
- } else {
84
-
85
- $("#{{ form.class.stock.vars.id }}").removeAttr("disabled");
86
-
87
- }
88
-
89
- $("#{{ form.class.stock_unlimited.vars.id }}").on("click change", function () {
90
-
91
- if ($(this).prop("checked")) {
92
-
93
- $("#{{ form.class.stock.vars.id }}").attr("disabled", "disabled").val('');
94
-
95
- } else {
96
-
97
- $("#{{ form.class.stock.vars.id }}").removeAttr("disabled");
98
-
99
- }
100
-
101
- });
102
-
103
- {% endif %}
104
-
105
- var proto_img = ''
106
-
107
- + '<li class="ui-state-default">'
108
-
109
- + '<img src="__path__" />'
110
-
111
- + '<a class="delete-image">'
112
-
113
- + '<svg class="cb cb-close">'
114
-
115
- + '<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#cb-close"></use>'
116
-
117
- + '</svg>'
118
-
119
- + '</a>'
120
-
121
- + '</li>';
122
-
123
- var proto_add = '{{ form_widget(form.add_images.vars.prototype) }}';
124
-
125
- var proto_del = '{{ form_widget(form.delete_images.vars.prototype) }}';
126
-
127
- {% for image in form.images %}
128
-
129
- var $img = $(proto_img.replace(/__path__/g, '{{ app.config.image_save_urlpath }}/{{ image.vars.value }}'));
130
-
131
- var $widget = $('{{ form_widget(image) }}');
132
-
133
- $widget.val('{{ image.vars.value }}');
134
-
135
- $("#thumb").append($img.append($widget));
136
-
137
- {% endfor %}
138
-
139
- {% for add_image in form.add_images %}
140
-
141
- var $img = $(proto_img.replace(/__path__/g, '{{ app.config.image_temp_urlpath }}/{{ add_image.vars.value }}'));
142
-
143
- var $widget = $('{{ form_widget(add_image) }}');
144
-
145
- $widget.val('{{ add_image.vars.value }}');
146
-
147
- $("#thumb").append($img.append($widget));
148
-
149
- {% endfor %}
150
-
151
- {% for delete_image in form.delete_images %}
152
-
153
- $("#thumb").append('{{ form_widget(delete_image) }}');
154
-
155
- {% endfor %}
156
-
157
- var hideSvg = function () {
158
-
159
- if ($("#thumb li").length > 0) {
160
-
161
- $("#icon_no_image").css("display", "none");
162
-
163
- } else {
164
-
165
- $("#icon_no_image").css("display", "");
166
-
167
- }
168
-
169
- };
170
-
171
- var updateRank = function () {
172
-
173
- $("#thumb li").each(function (index) {
174
-
175
- $(this).find(".rank_images").remove();
176
-
177
- filename = $(this).find("input[type='hidden']").val();
178
-
179
- $rank = $('<input type="hidden" class="rank_images" name="rank_images[]" />');
180
-
181
- $rank.val(filename + '//' + parseInt(index + 1));
182
-
183
- $(this).append($rank);
184
-
185
- });
186
-
187
- }
188
-
189
- hideSvg();
190
-
191
- updateRank();
192
-
193
- // 画像削除時
194
-
195
- var count_del = 0;
196
-
197
- $("#thumb").on("click", ".delete-image", function () {
198
-
199
- var $new_delete_image = $(proto_del.replace(/__name__/g, count_del));
200
-
201
- var src = $(this).prev().attr('src')
202
-
203
- .replace('{{ app.config.image_temp_urlpath }}/', '')
204
-
205
- .replace('{{ app.config.image_save_urlpath }}/', '');
206
-
207
- $new_delete_image.val(src);
208
-
209
- $("#thumb").append($new_delete_image);
210
-
211
- $(this).parent("li").remove();
212
-
213
- hideSvg();
214
-
215
- updateRank();
216
-
217
- count_del++;
218
-
219
- });
220
-
221
- var count_add = {{ form.add_images|length|default(0) }};
222
-
223
- $('#{{ form.product_image.vars.id }}').fileupload({
224
-
225
- url: "{{ url('admin_product_image_add') }}",
226
-
227
- type: "post",
228
-
229
- dataType: 'json',
230
-
231
- done: function (e, data) {
232
-
233
- $('#progress').hide();
234
-
235
- $.each(data.result.files, function (index, file) {
236
-
237
- var path = '{{ app.config.image_temp_urlpath }}/' + file;
238
-
239
- var $img = $(proto_img.replace(/__path__/g, path));
240
-
241
- var $new_img = $(proto_add.replace(/__name__/g, count_add));
242
-
243
- $new_img.val(file);
244
-
245
- $child = $img.append($new_img);
246
-
247
- $('#thumb').append($child);
248
-
249
- count_add++;
250
-
251
- });
252
-
253
- hideSvg();
254
-
255
- updateRank();
256
-
257
- },
258
-
259
- fail: function (e, data) {
260
-
261
- alert('アップロードに失敗しました。');
262
-
263
- },
264
-
265
- always: function (e, data) {
266
-
267
- $('#progress').hide();
268
-
269
- $('#progress .progress-bar').width('0%');
270
-
271
- },
272
-
273
- start: function (e, data) {
274
-
275
- $('#progress').show();
276
-
277
- },
278
-
279
- acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
280
-
281
- maxFileSize: 10000000,
282
-
283
- maxNumberOfFiles: 10,
284
-
285
- progressall: function (e, data) {
286
-
287
- var progress = parseInt(data.loaded / data.total * 100, 10);
288
-
289
- $('#progress .progress-bar').css(
290
-
291
- 'width',
292
-
293
- progress + '%'
294
-
295
- );
296
-
297
- },
298
-
299
- processalways: function (e, data) {
300
-
301
- if (data.files.error) {
302
-
303
- alert("画像ファイルサイズが大きいか画像ファイルではありません。");
304
-
305
- }
306
-
307
- }
308
-
309
- });
310
-
311
- // 画像アップロード
312
-
313
- $('#file_upload').on('click', function () {
314
-
315
- $('#{{ form.product_image.vars.id }}').click();
316
-
317
- });
318
-
319
- });
320
-
321
-
322
-
323
- function fnClass(action) {
324
-
325
- document.form1.action = action;
326
-
327
- document.form1.submit();
328
-
329
- return false;
330
-
331
- }
332
-
333
-
334
-
335
- </script>
336
-
337
- ```
338
-
339
-
340
-
341
-
342
-
343
- ECCUBE3ではjqueryで画像をアップロードしているようでした。
344
-
345
- ```
346
-
347
- <script src="/ec/html/template/admin/assets/js/vendor/fileupload/vendor/jquery.ui.widget.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.iframe-transport.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.fileupload.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.fileupload-process.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.fileupload-validate.js"></script>
348
-
349
- ```

3

読み込みjs追加

2017/06/01 04:43

投稿

oyashiro
oyashiro

スコア37

test CHANGED
File without changes
test CHANGED
@@ -335,3 +335,15 @@
335
335
  </script>
336
336
 
337
337
  ```
338
+
339
+
340
+
341
+
342
+
343
+ ECCUBE3ではjqueryで画像をアップロードしているようでした。
344
+
345
+ ```
346
+
347
+ <script src="/ec/html/template/admin/assets/js/vendor/fileupload/vendor/jquery.ui.widget.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.iframe-transport.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.fileupload.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.fileupload-process.js"></script><script src="/ec/html/template/admin/assets/js/vendor/fileupload/jquery.fileupload-validate.js"></script>
348
+
349
+ ```

2

商品マスタ画面のJavascriptを追加しました。

2017/06/01 02:08

投稿

oyashiro
oyashiro

スコア37

test CHANGED
File without changes
test CHANGED
@@ -45,3 +45,293 @@
45
45
  }
46
46
 
47
47
  ```
48
+
49
+
50
+
51
+
52
+
53
+ Javascript追記
54
+
55
+ ```
56
+
57
+ <script>
58
+
59
+ $(function() {
60
+
61
+ $("#thumb").sortable({
62
+
63
+ cursor: 'move',
64
+
65
+ opacity: 0.7,
66
+
67
+ placeholder: 'ui-state-highlight',
68
+
69
+ update: function (event, ui) {
70
+
71
+ updateRank();
72
+
73
+ }
74
+
75
+ });
76
+
77
+ {% if has_class == false %}
78
+
79
+ if ($("#{{ form.class.stock_unlimited.vars.id }}").prop("checked")) {
80
+
81
+ $("#{{ form.class.stock.vars.id }}").attr("disabled", "disabled").val('');
82
+
83
+ } else {
84
+
85
+ $("#{{ form.class.stock.vars.id }}").removeAttr("disabled");
86
+
87
+ }
88
+
89
+ $("#{{ form.class.stock_unlimited.vars.id }}").on("click change", function () {
90
+
91
+ if ($(this).prop("checked")) {
92
+
93
+ $("#{{ form.class.stock.vars.id }}").attr("disabled", "disabled").val('');
94
+
95
+ } else {
96
+
97
+ $("#{{ form.class.stock.vars.id }}").removeAttr("disabled");
98
+
99
+ }
100
+
101
+ });
102
+
103
+ {% endif %}
104
+
105
+ var proto_img = ''
106
+
107
+ + '<li class="ui-state-default">'
108
+
109
+ + '<img src="__path__" />'
110
+
111
+ + '<a class="delete-image">'
112
+
113
+ + '<svg class="cb cb-close">'
114
+
115
+ + '<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#cb-close"></use>'
116
+
117
+ + '</svg>'
118
+
119
+ + '</a>'
120
+
121
+ + '</li>';
122
+
123
+ var proto_add = '{{ form_widget(form.add_images.vars.prototype) }}';
124
+
125
+ var proto_del = '{{ form_widget(form.delete_images.vars.prototype) }}';
126
+
127
+ {% for image in form.images %}
128
+
129
+ var $img = $(proto_img.replace(/__path__/g, '{{ app.config.image_save_urlpath }}/{{ image.vars.value }}'));
130
+
131
+ var $widget = $('{{ form_widget(image) }}');
132
+
133
+ $widget.val('{{ image.vars.value }}');
134
+
135
+ $("#thumb").append($img.append($widget));
136
+
137
+ {% endfor %}
138
+
139
+ {% for add_image in form.add_images %}
140
+
141
+ var $img = $(proto_img.replace(/__path__/g, '{{ app.config.image_temp_urlpath }}/{{ add_image.vars.value }}'));
142
+
143
+ var $widget = $('{{ form_widget(add_image) }}');
144
+
145
+ $widget.val('{{ add_image.vars.value }}');
146
+
147
+ $("#thumb").append($img.append($widget));
148
+
149
+ {% endfor %}
150
+
151
+ {% for delete_image in form.delete_images %}
152
+
153
+ $("#thumb").append('{{ form_widget(delete_image) }}');
154
+
155
+ {% endfor %}
156
+
157
+ var hideSvg = function () {
158
+
159
+ if ($("#thumb li").length > 0) {
160
+
161
+ $("#icon_no_image").css("display", "none");
162
+
163
+ } else {
164
+
165
+ $("#icon_no_image").css("display", "");
166
+
167
+ }
168
+
169
+ };
170
+
171
+ var updateRank = function () {
172
+
173
+ $("#thumb li").each(function (index) {
174
+
175
+ $(this).find(".rank_images").remove();
176
+
177
+ filename = $(this).find("input[type='hidden']").val();
178
+
179
+ $rank = $('<input type="hidden" class="rank_images" name="rank_images[]" />');
180
+
181
+ $rank.val(filename + '//' + parseInt(index + 1));
182
+
183
+ $(this).append($rank);
184
+
185
+ });
186
+
187
+ }
188
+
189
+ hideSvg();
190
+
191
+ updateRank();
192
+
193
+ // 画像削除時
194
+
195
+ var count_del = 0;
196
+
197
+ $("#thumb").on("click", ".delete-image", function () {
198
+
199
+ var $new_delete_image = $(proto_del.replace(/__name__/g, count_del));
200
+
201
+ var src = $(this).prev().attr('src')
202
+
203
+ .replace('{{ app.config.image_temp_urlpath }}/', '')
204
+
205
+ .replace('{{ app.config.image_save_urlpath }}/', '');
206
+
207
+ $new_delete_image.val(src);
208
+
209
+ $("#thumb").append($new_delete_image);
210
+
211
+ $(this).parent("li").remove();
212
+
213
+ hideSvg();
214
+
215
+ updateRank();
216
+
217
+ count_del++;
218
+
219
+ });
220
+
221
+ var count_add = {{ form.add_images|length|default(0) }};
222
+
223
+ $('#{{ form.product_image.vars.id }}').fileupload({
224
+
225
+ url: "{{ url('admin_product_image_add') }}",
226
+
227
+ type: "post",
228
+
229
+ dataType: 'json',
230
+
231
+ done: function (e, data) {
232
+
233
+ $('#progress').hide();
234
+
235
+ $.each(data.result.files, function (index, file) {
236
+
237
+ var path = '{{ app.config.image_temp_urlpath }}/' + file;
238
+
239
+ var $img = $(proto_img.replace(/__path__/g, path));
240
+
241
+ var $new_img = $(proto_add.replace(/__name__/g, count_add));
242
+
243
+ $new_img.val(file);
244
+
245
+ $child = $img.append($new_img);
246
+
247
+ $('#thumb').append($child);
248
+
249
+ count_add++;
250
+
251
+ });
252
+
253
+ hideSvg();
254
+
255
+ updateRank();
256
+
257
+ },
258
+
259
+ fail: function (e, data) {
260
+
261
+ alert('アップロードに失敗しました。');
262
+
263
+ },
264
+
265
+ always: function (e, data) {
266
+
267
+ $('#progress').hide();
268
+
269
+ $('#progress .progress-bar').width('0%');
270
+
271
+ },
272
+
273
+ start: function (e, data) {
274
+
275
+ $('#progress').show();
276
+
277
+ },
278
+
279
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
280
+
281
+ maxFileSize: 10000000,
282
+
283
+ maxNumberOfFiles: 10,
284
+
285
+ progressall: function (e, data) {
286
+
287
+ var progress = parseInt(data.loaded / data.total * 100, 10);
288
+
289
+ $('#progress .progress-bar').css(
290
+
291
+ 'width',
292
+
293
+ progress + '%'
294
+
295
+ );
296
+
297
+ },
298
+
299
+ processalways: function (e, data) {
300
+
301
+ if (data.files.error) {
302
+
303
+ alert("画像ファイルサイズが大きいか画像ファイルではありません。");
304
+
305
+ }
306
+
307
+ }
308
+
309
+ });
310
+
311
+ // 画像アップロード
312
+
313
+ $('#file_upload').on('click', function () {
314
+
315
+ $('#{{ form.product_image.vars.id }}').click();
316
+
317
+ });
318
+
319
+ });
320
+
321
+
322
+
323
+ function fnClass(action) {
324
+
325
+ document.form1.action = action;
326
+
327
+ document.form1.submit();
328
+
329
+ return false;
330
+
331
+ }
332
+
333
+
334
+
335
+ </script>
336
+
337
+ ```

1

2017/05/31 12:19

投稿

oyashiro
oyashiro

スコア37

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  下記のように、変数に変換しているのですが、
6
6
 
7
- どうすれば画像のURLのままファイル名が決定されますか?
7
+ どうすれば画像のファイル名のままファイル名が決定されますか?
8
8
 
9
9
 
10
10