このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
|
プログラム言語:javascript_jquery:dropzonejs:複数dropzoneのやり方 [2018/11/05 17:09] yusuke_komori |
プログラム言語:javascript_jquery:dropzonejs:複数dropzoneのやり方 [2018/11/05 17:59] (現在) yusuke_komori [up.php] |
||
|---|---|---|---|
| 行 19: | 行 19: | ||
| < | < | ||
| <form action=" | <form action=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | <input type=" | ||
| <ul> | <ul> | ||
| <li id=" | <li id=" | ||
| 行 35: | 行 38: | ||
| $(' | $(' | ||
| - | console.log(i + ': ' + $(elem).data(' | + | $('# |
| - | + | url: ' | |
| - | $('# | + | paramName: $(elem).data(' |
| - | url: ' | + | maxFiles: 1, |
| - | paramName: $(elem).data(' | + | maxfilesexceeded: |
| - | maxFiles: 1, | + | alert(' |
| - | maxfilesexceeded: | + | this.removeFile(file); |
| - | alert(' | + | }, |
| - | this.removeFile(file); | + | dictMaxFilesExceeded: |
| + | success: function(file, | ||
| + | if (result == ' | ||
| + | alert(' | ||
| + | this.removeFile(file); | ||
| + | return; | ||
| + | } | ||
| + | $(' | ||
| + | if (file.previewElement) { | ||
| + | return file.previewElement.classList.add(' | ||
| + | } | ||
| + | }, | ||
| + | addRemoveLinks: | ||
| + | dictRemoveFile: | ||
| + | removedfile: | ||
| + | var thisDropzone = this; | ||
| + | var postData = {}; | ||
| + | |||
| + | $.each($(elem).data(), | ||
| + | postData[j] = data; | ||
| + | }); | ||
| + | |||
| + | $.ajax({ | ||
| + | url: ' | ||
| + | type: ' | ||
| + | data: postData, | ||
| + | cache: false, | ||
| + | complete: function() { | ||
| + | $(' | ||
| + | |||
| + | var _ref; | ||
| + | if (file.previewElement) { | ||
| + | if ((_ref = file.previewElement) != null) { | ||
| + | _ref.parentNode.removeChild(file.previewElement); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | return thisDropzone._updateMaxFilesReachedClass(); | ||
| }, | }, | ||
| - | | + | error: function() { |
| + | alert(' | ||
| + | } | ||
| + | }); | ||
| + | }, | ||
| + | | ||
| }); | }); | ||
| </ | </ | ||
| 行 51: | 行 96: | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| + | ===== up.php ===== | ||
| + | < | ||
| + | <?php | ||
| + | if (!isset($_FILES) || count($_FILES) == 0) { | ||
| + | // エラー処理 | ||
| + | echo ' | ||
| + | exit; | ||
| + | } | ||
| + | |||
| + | // アップロード処理 | ||
| + | |||
| + | $key = key($_FILES); | ||
| + | |||
| + | echo $key . ' | ||
| + | |||
| + | /* | ||
| + | * 配列で返したい場合は、jsonにエンコードする | ||
| + | $result = [ | ||
| + | ' | ||
| + | ' | ||
| + | ]; | ||
| + | |||
| + | echo json_encode($result); | ||
| + | */ | ||
| + | </ | ||
| + | |||