質問編集履歴
11
問題点修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,11 +10,27 @@
|
|
10
10
|
|
11
11
|
解決策や実装方法などありましたら教えてください。
|
12
12
|
|
13
|
-
|
13
|
+
現在アップロードしたファイルを添付して送信する
|
14
|
+
|
15
|
+
という処理を行っているのですが、送信メールに
|
16
|
+
|
17
|
+
送信されません。
|
14
18
|
|
15
19
|
###発生している問題・エラーメッセージ
|
16
20
|
|
17
|
-
|
21
|
+
Content-Type: text/plain; charset="ISO-2022-JP"
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Content-Type: image/jpeg; name=""
|
26
|
+
|
27
|
+
Content-Transfer-Encoding: base64
|
28
|
+
|
29
|
+
Content-Disposition: attachment; filename=""
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
こんな感じになります。
|
18
34
|
|
19
35
|
###該当のソースコード
|
20
36
|
|
10
コードに修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,12 +10,10 @@
|
|
10
10
|
|
11
11
|
解決策や実装方法などありましたら教えてください。
|
12
12
|
|
13
|
-
|
13
|
+
|
14
14
|
|
15
15
|
###発生している問題・エラーメッセージ
|
16
16
|
|
17
|
-
Invalid argument supplied for foreach()
|
18
|
-
|
19
17
|
|
20
18
|
|
21
19
|
###該当のソースコード
|
@@ -38,7 +36,7 @@
|
|
38
36
|
|
39
37
|
```php
|
40
38
|
|
41
|
-
$dir ='img/upload';
|
39
|
+
$dir ='img/upload/';
|
42
40
|
|
43
41
|
const MAX_SIZE =2048000;
|
44
42
|
|
@@ -66,13 +64,7 @@
|
|
66
64
|
|
67
65
|
$tmp_name = $_FILES['uploadfile']['tmp_name'][$i];
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
$move_to= $dir . '/upfile_' .time() . $i . '_'
|
72
|
-
|
73
|
-
. md5(microtime() .$name . $_SERVER['REMOVE_ADDR'])
|
74
|
-
|
75
|
-
|
67
|
+
$move_to = $dir.$name;
|
76
68
|
|
77
69
|
if(move_uploaded_file($tmp_name,$move_to)){
|
78
70
|
|
@@ -88,7 +80,13 @@
|
|
88
80
|
|
89
81
|
}
|
90
82
|
|
91
|
-
|
83
|
+
$handle = fopen($move_to, 'r');
|
84
|
+
|
85
|
+
$attachFile = fread($handle, filesize($tmp_name));
|
86
|
+
|
87
|
+
fclose($handle);
|
88
|
+
|
89
|
+
$attachEncode = base64_encode($attachFile);
|
92
90
|
|
93
91
|
if(count($error_msg) > 0){
|
94
92
|
|
@@ -100,9 +98,9 @@
|
|
100
98
|
|
101
99
|
}
|
102
100
|
|
103
|
-
}
|
101
|
+
}
|
104
|
-
|
102
|
+
|
105
|
-
}
|
103
|
+
}
|
106
104
|
|
107
105
|
|
108
106
|
|
@@ -238,57 +236,99 @@
|
|
238
236
|
|
239
237
|
}
|
240
238
|
|
241
|
-
|
239
|
+
}
|
242
240
|
|
243
241
|
```
|
244
242
|
|
245
|
-
```
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
$
|
250
|
-
|
251
|
-
$
|
252
|
-
|
253
|
-
$
|
254
|
-
|
255
|
-
if(
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
$
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
$
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
$adminBody
|
290
|
-
|
291
|
-
$adminBody .=
|
243
|
+
```PHP
|
244
|
+
|
245
|
+
function adminHeader($userMail,$post_mail,$BccMail,$to){
|
246
|
+
|
247
|
+
$header = '';
|
248
|
+
|
249
|
+
if($userMail == 1 && !empty($post_mail)) {
|
250
|
+
|
251
|
+
$header="From: $post_mail\n";
|
252
|
+
|
253
|
+
if($BccMail != '') {
|
254
|
+
|
255
|
+
$header.="Bcc: $BccMail\n";
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
$header.="Reply-To: ".$post_mail."\n";
|
260
|
+
|
261
|
+
}else {
|
262
|
+
|
263
|
+
if($BccMail != '') {
|
264
|
+
|
265
|
+
$header="Bcc: $BccMail\n";
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
$header.="Reply-To: ".$to."\n";
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
$header.="Content-Type:text/plain;charset=iso-2022-jp\nX-Mailer: PHP/".phpversion();
|
274
|
+
|
275
|
+
return $header;
|
276
|
+
|
277
|
+
$header .= "MIME-Version: 1.0\n";
|
278
|
+
|
279
|
+
$header .= "Content-Type: multipart/mixed; boundary=\"__PHPRECIPE__\"";
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
function mailToAdmin($arr,$subject,$mailFooterDsp,$mailSignature,$encode,$confirmDsp){
|
286
|
+
|
287
|
+
$adminBody="「".$subject."」フォームから送信されました\n\n";
|
288
|
+
|
289
|
+
$adminBody .="Content-Type: text/plain; charset=\"ISO-2022-JP\"\r\n";
|
290
|
+
|
291
|
+
$adminBody .="\r\n";
|
292
|
+
|
293
|
+
$move_to = mb_encode_mimeheader($move_to, "ISO-2022-JP", "B");
|
294
|
+
|
295
|
+
$adminBody .="Content-Type: image/jpeg; name=\"$name\"\r\n";
|
296
|
+
|
297
|
+
$adminBody .="Content-Transfer-Encoding: base64\r\n";
|
298
|
+
|
299
|
+
$adminBody .="Content-Disposition: attachment; filename=\"$name\"\r\n";
|
300
|
+
|
301
|
+
$adminBody .="\r\n";
|
302
|
+
|
303
|
+
$adminBody .= chunk_split($attachEncode) . "\r\n";
|
304
|
+
|
305
|
+
$adminBody .="===========================\n\n";
|
306
|
+
|
307
|
+
$adminBody.= postToMail($arr);//POSTデータを関数からセット
|
308
|
+
|
309
|
+
$adminBody.="\n===========================\n";
|
310
|
+
|
311
|
+
$adminBody.="送信された日時:".date( "Y/m/d (D) H:i:s", time() )."\n";
|
312
|
+
|
313
|
+
$adminBody.="送信者のIPアドレス:".@$_SERVER["REMOTE_ADDR"]."\n";
|
314
|
+
|
315
|
+
$adminBody.="送信者のホスト名:".getHostByAddr(getenv('REMOTE_ADDR'))."\n";
|
316
|
+
|
317
|
+
if($confirmDsp != 1){
|
318
|
+
|
319
|
+
$adminBody.="問い合わせのページURL:".@$_SERVER['HTTP_REFERER']."\n";
|
320
|
+
|
321
|
+
}else{
|
322
|
+
|
323
|
+
$adminBody.="問い合わせのページURL:".@$arr['httpReferer']."\n";
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
if($mailFooterDsp == 1) $adminBody.= $mailSignature;
|
328
|
+
|
329
|
+
return mb_convert_encoding($adminBody,"JIS",$encode);
|
330
|
+
|
331
|
+
}
|
292
332
|
|
293
333
|
```
|
294
334
|
|
9
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -244,27 +244,39 @@
|
|
244
244
|
|
245
245
|
```php
|
246
246
|
|
247
|
+
$fileMoveDir = "img/upload/";
|
248
|
+
|
249
|
+
$moveFileName[0] = "test0.xls";
|
250
|
+
|
251
|
+
$moveFileName[1] = "test1.xls";
|
252
|
+
|
253
|
+
$moveFileName[2] = "test2.xls";
|
254
|
+
|
247
255
|
if(isset($_FILES['uploadfile'])){
|
248
256
|
|
249
|
-
for($i = 0; $i < count($_FILES['uploadfile']
|
257
|
+
for($i = 0; $i < count($_FILES['uploadfile']); $i++){
|
250
|
-
|
258
|
+
|
251
|
-
$name = $_FILES['uploadfile']['name']
|
259
|
+
$name = $_FILES['uploadfile'][$i]['name'];
|
252
|
-
|
260
|
+
|
253
|
-
$filename = $_FILES['uploadfile']['tmp_name']
|
261
|
+
$filename = $_FILES['uploadfile'][$i]['tmp_name'];
|
262
|
+
|
263
|
+
|
264
|
+
|
254
|
-
|
265
|
+
move_uploaded_file($_FILES["uploadfile"]["tmp_name"],$fileMoveDir.$moveFileName[$i]);
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
$handle = fopen($fileMoveDir.$moveFileName[$i], 'r');
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
$attachFile = fread($handle, filesize($filename));
|
274
|
+
|
275
|
+
fclose($handle);
|
276
|
+
|
277
|
+
$attachEncode = base64_encode($attachFile);
|
278
|
+
|
255
|
-
}
|
279
|
+
}
|
256
|
-
|
257
|
-
foreach($filename as $key => $value){
|
258
|
-
|
259
|
-
$handle[$key] = fopen($value, 'r');
|
260
|
-
|
261
|
-
$attachFile =fread($handle, filesize($filename));
|
262
|
-
|
263
|
-
fclose($handle);
|
264
|
-
|
265
|
-
$attachEncode = base64_encode($attachFile);
|
266
|
-
|
267
|
-
}
|
268
280
|
|
269
281
|
}
|
270
282
|
|
8
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,55 +14,9 @@
|
|
14
14
|
|
15
15
|
###発生している問題・エラーメッセージ
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
20
|
-
|
21
|
-
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
22
|
-
|
23
|
-
|
17
|
+
Invalid argument supplied for foreach()
|
24
|
-
|
25
|
-
|
18
|
+
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
19
|
+
|
30
|
-
|
31
|
-
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
32
|
-
|
33
|
-
Warning: fread() expects parameter 1 to be resource, array given in
|
34
|
-
|
35
|
-
Warning: fclose() expects parameter 1 to be resource, array given in
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
40
|
-
|
41
|
-
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
42
|
-
|
43
|
-
Warning: fread() expects parameter 1 to be resource, array given in
|
44
|
-
|
45
|
-
Warning: fclose() expects parameter 1 to be resource, array given in
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
50
|
-
|
51
|
-
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
52
|
-
|
53
|
-
Warning: fread() expects parameter 1 to be resource, array given in
|
54
|
-
|
55
|
-
Warning: fclose() expects parameter 1 to be resource, array given in
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
60
|
-
|
61
|
-
Warning: filesize() expects parameter 1 to be a valid path, array given
|
62
|
-
|
63
|
-
Warning: fread() expects parameter 1 to be resource, array given in
|
64
|
-
|
65
|
-
Warning: fclose() expects parameter 1 to be resource, array given in
|
66
20
|
|
67
21
|
###該当のソースコード
|
68
22
|
|
@@ -290,9 +244,15 @@
|
|
290
244
|
|
291
245
|
```php
|
292
246
|
|
293
|
-
|
247
|
+
if(isset($_FILES['uploadfile'])){
|
248
|
+
|
294
|
-
|
249
|
+
for($i = 0; $i < count($_FILES['uploadfile']['name']); $i++){
|
250
|
+
|
295
|
-
|
251
|
+
$name = $_FILES['uploadfile']['name'][$i];
|
252
|
+
|
253
|
+
$filename = $_FILES['uploadfile']['tmp_name'][$i];
|
254
|
+
|
255
|
+
}
|
296
256
|
|
297
257
|
foreach($filename as $key => $value){
|
298
258
|
|
@@ -306,9 +266,7 @@
|
|
306
266
|
|
307
267
|
}
|
308
268
|
|
309
|
-
|
269
|
+
}
|
310
|
-
|
311
|
-
|
312
270
|
|
313
271
|
$adminBody .="Content-Type: image/jpeg; name=\"$filename\"\r\n";
|
314
272
|
|
7
エラーの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,9 +16,53 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
20
|
+
|
21
|
+
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
22
|
+
|
19
|
-
Warning:
|
23
|
+
Warning: fread() expects parameter 1 to be resource, array given in
|
24
|
+
|
20
|
-
|
25
|
+
Warning: fclose() expects parameter 1 to be resource, array given in
|
26
|
+
|
27
|
+
|
28
|
+
|
21
|
-
|
29
|
+
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
30
|
+
|
31
|
+
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
32
|
+
|
33
|
+
Warning: fread() expects parameter 1 to be resource, array given in
|
34
|
+
|
35
|
+
Warning: fclose() expects parameter 1 to be resource, array given in
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
40
|
+
|
41
|
+
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
42
|
+
|
43
|
+
Warning: fread() expects parameter 1 to be resource, array given in
|
44
|
+
|
45
|
+
Warning: fclose() expects parameter 1 to be resource, array given in
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
50
|
+
|
51
|
+
Warning: filesize() expects parameter 1 to be a valid path, array given in
|
52
|
+
|
53
|
+
Warning: fread() expects parameter 1 to be resource, array given in
|
54
|
+
|
55
|
+
Warning: fclose() expects parameter 1 to be resource, array given in
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Warning: fopen() expects parameter 1 to be a valid path, array given in
|
60
|
+
|
61
|
+
Warning: filesize() expects parameter 1 to be a valid path, array given
|
62
|
+
|
63
|
+
Warning: fread() expects parameter 1 to be resource, array given in
|
64
|
+
|
65
|
+
Warning: fclose() expects parameter 1 to be resource, array given in
|
22
66
|
|
23
67
|
###該当のソースコード
|
24
68
|
|
@@ -246,7 +290,7 @@
|
|
246
290
|
|
247
291
|
```php
|
248
292
|
|
249
|
-
$filename = $_
|
293
|
+
$filename = $_FILES['uploadfile'];
|
250
294
|
|
251
295
|
|
252
296
|
|
6
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
```
|
40
40
|
|
41
|
-
```php
|
41
|
+
```php
|
42
42
|
|
43
43
|
$dir ='img/upload';
|
44
44
|
|
5
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,211 @@
|
|
38
38
|
|
39
39
|
```
|
40
40
|
|
41
|
-
|
41
|
+
```phpアップロード
|
42
|
+
|
43
|
+
$dir ='img/upload';
|
44
|
+
|
45
|
+
const MAX_SIZE =2048000;
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
if(! checkPostMaxSize()){
|
50
|
+
|
51
|
+
echo 'ファイルサイズは2MB以下にしてください<br><br>';
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
if(isset($_FILES['uploadfile'])){
|
58
|
+
|
59
|
+
for($i = 0; $i <count($_FILES['uploadfile']['name']); $i++){
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
list($result, $ext, $error_msg) = checkFile($i);
|
64
|
+
|
65
|
+
if($result){
|
66
|
+
|
67
|
+
$name = $_FILES['uploadfile']['name'][$i];
|
68
|
+
|
69
|
+
$tmp_name = $_FILES['uploadfile']['tmp_name'][$i];
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
$move_to= $dir . '/upfile_' .time() . $i . '_'
|
74
|
+
|
75
|
+
. md5(microtime() .$name . $_SERVER['REMOVE_ADDR'])
|
76
|
+
|
77
|
+
. '.' . $ext;
|
78
|
+
|
79
|
+
if(move_uploaded_file($tmp_name,$move_to)){
|
80
|
+
|
81
|
+
echo h($move_to) . '<br>';
|
82
|
+
|
83
|
+
echo '<img src="' . h($move_to). '" alt="アップロードされた画像"><br>';
|
84
|
+
|
85
|
+
}else{
|
86
|
+
|
87
|
+
$error_msg[] = '画像のアップロードに失敗しました';
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
if(count($error_msg) > 0){
|
96
|
+
|
97
|
+
foreach($error_msg as $msg){
|
98
|
+
|
99
|
+
echo h($msg). '<br>';
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
function checkFile($i)
|
112
|
+
|
113
|
+
{
|
114
|
+
|
115
|
+
$error_msg = array();
|
116
|
+
|
117
|
+
$ext ='';
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
$size =$_FILES['uploadfile']['size'][$i];
|
122
|
+
|
123
|
+
$error =$_FILES['uploadfile']['error'][$i];
|
124
|
+
|
125
|
+
$img_type =$_FILES['uploadfile']['type'][$i];
|
126
|
+
|
127
|
+
$tmp_name =$_FILES['uploadfile']['tmp_name'][$i];
|
128
|
+
|
129
|
+
if($error != UPLOAD_ERR_OK){
|
130
|
+
|
131
|
+
if($error == UPLOAD_ERR_NO_FILE){
|
132
|
+
|
133
|
+
}elseif ($error == UPLOAD_ERR_INT_SIZE ||
|
134
|
+
|
135
|
+
$error == UPLOAD_ERR_FORM_SIZE){
|
136
|
+
|
137
|
+
$error_msg[] ='ファイルサイズは100KB以下にしてください';
|
138
|
+
|
139
|
+
}else{
|
140
|
+
|
141
|
+
$error_msg[] = 'アップロードエラーです';
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
return array(false, $ext, $error_msg);
|
146
|
+
|
147
|
+
}else{
|
148
|
+
|
149
|
+
if($img_type == 'image/gif'){
|
150
|
+
|
151
|
+
$ext ='gif';
|
152
|
+
|
153
|
+
} elseif ($img_type == 'image/jpeg' || $img_type == 'image/pjpeg'){
|
154
|
+
|
155
|
+
$ext = 'jpg';
|
156
|
+
|
157
|
+
} elseif ($img_type == 'image/png' || $img_type == 'image/x-png'){
|
158
|
+
|
159
|
+
$ext = 'png';
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
166
|
+
|
167
|
+
$finfoType = $finfo->file($tmp_name);
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
if($size == 0){
|
172
|
+
|
173
|
+
$error_msg[] ='ファイルが存在しないか空のファイルです。';
|
174
|
+
|
175
|
+
}elseif ($size > MAX_SIZE){
|
176
|
+
|
177
|
+
$error_msg[] ='ファイルサイズは100KB以下にしてください';
|
178
|
+
|
179
|
+
}elseif ($img_type != $finfoType){
|
180
|
+
|
181
|
+
$error_msg[] ='MIMEタイプが一致しません';
|
182
|
+
|
183
|
+
}elseif ($ext != 'gif' && $ext !='jpg' && $ext != 'png'){
|
184
|
+
|
185
|
+
$error_msg[] ='アップロード可能なファイルはgif、jpg、pngのみです';
|
186
|
+
|
187
|
+
}else{
|
188
|
+
|
189
|
+
return array(true, $ext, $error_msg);
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
return array(false, $ext, $error_msg);
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
function checkPostMaxSize()
|
202
|
+
|
203
|
+
{
|
204
|
+
|
205
|
+
$max_size = ini_get('post_max_size');
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
$multiple= 1;
|
210
|
+
|
211
|
+
$unit = substr($max_size, -1);
|
212
|
+
|
213
|
+
if($unit == 'M'){
|
214
|
+
|
215
|
+
$multiple= 1024*1024;
|
216
|
+
|
217
|
+
} elseif ($unit == 'K'){
|
218
|
+
|
219
|
+
$multiple =1024;
|
220
|
+
|
221
|
+
} elseif ($unit == 'G'){
|
222
|
+
|
223
|
+
$multiple =1024*1024*1024;
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
$max_size = substr($max_size, 0, strlen($max_size) - 1)* $multiple;
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
|
232
|
+
|
233
|
+
$_SERVER['CONTENT_LENGTH'] > $max_size){
|
234
|
+
|
235
|
+
return false;
|
236
|
+
|
237
|
+
}else{
|
238
|
+
|
239
|
+
return true;
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
```
|
42
246
|
|
43
247
|
```php
|
44
248
|
|
4
エラー
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,15 +16,7 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
Warning:
|
19
|
+
Warning: Invalid argument supplied for foreach() in
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
Warning: fread() expects parameter 1 to be resource, boolean given in /kinki/mail.php on line 520
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
Warning: fclose() expects parameter 1 to be resource, boolean given in /kinki/mail.php on line 521
|
28
20
|
|
29
21
|
|
30
22
|
|
3
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,17 +52,19 @@
|
|
52
52
|
|
53
53
|
$filename = $_POST['uploadfile'];
|
54
54
|
|
55
|
+
|
56
|
+
|
55
57
|
foreach($filename as $key => $value){
|
56
58
|
|
57
59
|
$handle[$key] = fopen($value, 'r');
|
58
60
|
|
61
|
+
$attachFile =fread($handle, filesize($filename));
|
62
|
+
|
63
|
+
fclose($handle);
|
64
|
+
|
65
|
+
$attachEncode = base64_encode($attachFile);
|
66
|
+
|
59
67
|
}
|
60
|
-
|
61
|
-
$attachFile =fread($handle, filesize($filename));
|
62
|
-
|
63
|
-
fclose($handle);
|
64
|
-
|
65
|
-
$attachEncode = base64_encode($attachFile);
|
66
68
|
|
67
69
|
|
68
70
|
|
2
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,9 +50,13 @@
|
|
50
50
|
|
51
51
|
```php
|
52
52
|
|
53
|
-
$filename=$_POST['uploadfile'];
|
53
|
+
$filename = $_POST['uploadfile'];
|
54
54
|
|
55
|
+
foreach($filename as $key => $value){
|
56
|
+
|
55
|
-
$handle = fopen($
|
57
|
+
$handle[$key] = fopen($value, 'r');
|
58
|
+
|
59
|
+
}
|
56
60
|
|
57
61
|
$attachFile =fread($handle, filesize($filename));
|
58
62
|
|
1
コードブロックでの囲み
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,9 @@
|
|
30
30
|
|
31
31
|
###該当のソースコード
|
32
32
|
|
33
|
+
|
34
|
+
|
33
|
-
|
35
|
+
```html
|
34
36
|
|
35
37
|
<form id="testform" method="post" action="mail.php" enctype="multipart/form-data">
|
36
38
|
|
@@ -42,9 +44,13 @@
|
|
42
44
|
|
43
45
|
</form>
|
44
46
|
|
45
|
-
|
47
|
+
```
|
46
48
|
|
49
|
+
|
50
|
+
|
51
|
+
```php
|
52
|
+
|
47
|
-
$filename=$POST
|
53
|
+
$filename=$_POST['uploadfile'];
|
48
54
|
|
49
55
|
$handle = fopen($filename, 'r');
|
50
56
|
|
@@ -68,6 +74,8 @@
|
|
68
74
|
|
69
75
|
$adminBody .= chunk_split($attachEncode) . "\r\n";
|
70
76
|
|
77
|
+
```
|
78
|
+
|
71
79
|
###試したこと
|
72
80
|
|
73
81
|
課題に対してアプローチしたことを記載してください
|