質問するログイン新規登録

質問編集履歴

1

HTML, JavaScriptのソースコードを掲示

2019/08/02 10:48

投稿

user0001
user0001

スコア13

title CHANGED
File without changes
body CHANGED
@@ -17,4 +17,79 @@
17
17
  PHPに詳しくなく、この辺りの仕様を理解できていません。
18
18
  他に情報が必要でしたらご指摘を頂けると幸いです。
19
19
 
20
- 宜しくお願い致します。
20
+ 宜しくお願い致します。
21
+
22
+ ---
23
+ **追記**:関係していると思われる個所を掲示させていただきます。
24
+
25
+ ```form
26
+ <form method="post" action="" id="form" class="files-container" style="background-color: rgb(248,248,248);text-align: center;" enctype="multipart/form-data">
27
+ <div class="form-group"><input class="form-control" type="text" name="title" placeholder="タイトル" style="margin-top: 8px;margin-bottom: 8px;" required=""></div>
28
+ <div class="form-group"><button id="dropzoneSubmit" class="btn btn-primary btn-block d-xl-flex justify-content-xl-center" style="font-size: 16px;margin-top: 64px;">公開する</button>
29
+ </div>
30
+ <input type="submit" value="" style="display:none" name="publish">
31
+ </form>
32
+ ```
33
+
34
+ ```javascript
35
+ <script type="text/javascript">
36
+ Dropzone.autoDiscover = false;
37
+ $(document).ready(function() {
38
+ var myDropzone = new Dropzone("#myDropzone", {
39
+ url: "",
40
+ paramName: "file",
41
+ autoProcessQueue: false,
42
+ uploadMultiple: true,
43
+ parallelUploads: 100,
44
+ maxFilesize: 3,
45
+ maxFiles: 10,
46
+ acceptedFiles: ".jpg, .jpeg, .png, .gif",
47
+ addRemoveLinks: true,
48
+ dictFileTooBig: "この画像のサイズは{{filesize}}MBです. 最大サイズは{{maxFilesize}}MBです",
49
+ dictInvalidFileType: "対応している拡張子はJPG, JPEG, PNG, GIFのみです",
50
+ dictCancelUpload: "キャンセル",
51
+ dictRemoveFile: "削除",
52
+ dictMaxFilesExceeded: "アップロード可能な枚数は最大{{maxFiles}}枚です",
53
+ dictDefaultMessage: "画像を選択してください",
54
+ });
55
+ });
56
+ Dropzone.options.myDropzone = {
57
+ init: function() {
58
+ var pf = false;
59
+ var myDropzone = this;
60
+ $("#dropzoneSubmit").on("click", function(e) {
61
+ e.preventDefault();
62
+ e.stopPropagation();
63
+
64
+ if(pf){
65
+ $("input[name=publish]").click();
66
+ }
67
+
68
+ if (myDropzone.files != "") {
69
+ myDropzone.processQueue();
70
+ } else {
71
+ $("#myDropzone").submit();
72
+ }
73
+ });
74
+ // ファイル追加時
75
+ this.on("addedfile", function(file) {
76
+ // console.log(file);
77
+ });
78
+ // エラー時
79
+ this.on("error", function(file, response) {
80
+ // console.log(response);
81
+ });
82
+ // アップロード開始時
83
+ this.on("sendingmultiple", function(file) {
84
+ // console.log(file);
85
+ });
86
+ // アップロード成功時
87
+ this.on("successmultiple", function(file) {
88
+ // submit form
89
+ pf = true;
90
+ $("input[name=publish]").click();
91
+ });
92
+ }
93
+ };
94
+ </script>
95
+ ```