回答編集履歴
2
type
test
CHANGED
@@ -114,7 +114,7 @@
|
|
114
114
|
|
115
115
|
</script>
|
116
116
|
|
117
|
-
<form id="f1" action="
|
117
|
+
<form id="f1" action="recv.php" method="post" enctype="multipart/form-data">
|
118
118
|
|
119
119
|
<input type="hidden" name="group_no" value="10005">
|
120
120
|
|
1
追記
test
CHANGED
@@ -15,3 +15,117 @@
|
|
15
15
|
ただ順番におくる意味があるかといわれると微妙です。
|
16
16
|
|
17
17
|
一緒におくって、サーバー側で順番に処理すればいいような気がします
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
# 単純パターン
|
22
|
+
|
23
|
+
- send.html
|
24
|
+
|
25
|
+
```HTML
|
26
|
+
|
27
|
+
<form id="f1" action="recv.php" method="post" enctype="multipart/form-data">
|
28
|
+
|
29
|
+
<input type="hidden" name="group_no" value="10005">
|
30
|
+
|
31
|
+
<input type="file" name="f[]"><br>
|
32
|
+
|
33
|
+
<input type="file" name="f[]"><br>
|
34
|
+
|
35
|
+
<input type="file" name="f[]"><br>
|
36
|
+
|
37
|
+
<input type="submit" value="go">
|
38
|
+
|
39
|
+
</form>
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
- recv.php
|
44
|
+
|
45
|
+
```PHP
|
46
|
+
|
47
|
+
<?PHP
|
48
|
+
|
49
|
+
$group_no=filter_input(INPUT_POST,"group_no");
|
50
|
+
|
51
|
+
$uploads_dir = '/uploads';
|
52
|
+
|
53
|
+
if(count($_FILES)>0){
|
54
|
+
|
55
|
+
foreach($_FILES["f"]["tmp_name"] as $key=>$tmp_name){
|
56
|
+
|
57
|
+
if($_FILES["f"]["error"][$key]>0) continue;
|
58
|
+
|
59
|
+
$up=$uploads_dir."/".$group_no.($key+1);
|
60
|
+
|
61
|
+
echo "move_uploaded_file('$tmp_name','$up');\n";
|
62
|
+
|
63
|
+
//move_uploaded_file($tmp_name, $up); //実際にはこちらを利用
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
?>
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
# 画面遷移しない
|
76
|
+
|
77
|
+
- send.html
|
78
|
+
|
79
|
+
```HTML
|
80
|
+
|
81
|
+
<script>
|
82
|
+
|
83
|
+
$(function(){
|
84
|
+
|
85
|
+
$('#f1').on('submit',function(e){
|
86
|
+
|
87
|
+
e.preventDefault();
|
88
|
+
|
89
|
+
var fd=new FormData($(this).get(0));
|
90
|
+
|
91
|
+
$.ajax({
|
92
|
+
|
93
|
+
"url":$(this).attr('action'),
|
94
|
+
|
95
|
+
"type":"post",
|
96
|
+
|
97
|
+
"data":fd,
|
98
|
+
|
99
|
+
"cache":false,
|
100
|
+
|
101
|
+
"processData": false,
|
102
|
+
|
103
|
+
"contentType": false,
|
104
|
+
|
105
|
+
}).done(function(data){
|
106
|
+
|
107
|
+
console.log(data);
|
108
|
+
|
109
|
+
});
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
});
|
114
|
+
|
115
|
+
</script>
|
116
|
+
|
117
|
+
<form id="f1" action="y.php" method="post" enctype="multipart/form-data">
|
118
|
+
|
119
|
+
<input type="hidden" name="group_no" value="10005">
|
120
|
+
|
121
|
+
<input type="file" name="f[]"><br>
|
122
|
+
|
123
|
+
<input type="file" name="f[]"><br>
|
124
|
+
|
125
|
+
<input type="file" name="f[]"><br>
|
126
|
+
|
127
|
+
<input type="submit" value="go">
|
128
|
+
|
129
|
+
</form>
|
130
|
+
|
131
|
+
```
|