回答編集履歴

4

修正

2016/06/07 04:37

投稿

退会済みユーザー
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- if (null != filter_input_array(INPUT_POST) && $_FILES['userfile']['error'] == 0) {
27
+ if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] == 0) {
28
28
 
29
29
  $tmp_name = $_FILES['userfile']['tmp_name'];
30
30
 

3

修正

2016/06/07 04:37

投稿

退会済みユーザー
test CHANGED
@@ -7,6 +7,10 @@
7
7
  ```php
8
8
 
9
9
  <?php
10
+
11
+ ini_set('display_errors', 1);
12
+
13
+ error_reporting(E_ALL);
10
14
 
11
15
 
12
16
 
@@ -20,7 +24,7 @@
20
24
 
21
25
 
22
26
 
23
- if ($_FILES['userfile']['error'] == 0) {
27
+ if (null != filter_input_array(INPUT_POST) && $_FILES['userfile']['error'] == 0) {
24
28
 
25
29
  $tmp_name = $_FILES['userfile']['tmp_name'];
26
30
 
@@ -48,37 +52,41 @@
48
52
 
49
53
  <html lang="ja">
50
54
 
51
- <head>
55
+ <head>
52
56
 
53
- <meta charset="UTF-8">
57
+ <meta charset="UTF-8">
54
58
 
55
- <title></title>
59
+ <title></title>
56
60
 
57
- </head>
61
+ </head>
58
62
 
59
- <body>
63
+ <body>
60
64
 
61
65
  <h1>csvアップロード</h1>
62
66
 
63
67
 
64
68
 
65
- <form method="post" action="" enctype="multipart/form-data">
69
+ <form method="post" action="" enctype="multipart/form-data">
66
70
 
67
- <input type="file" name="userfile" />
71
+ <input type="file" name="userfile" />
68
72
 
69
- <button type="submit">upload</button>
73
+ <button type="submit">upload</button>
70
74
 
71
- </form>
75
+ </form>
72
76
 
73
77
 
74
78
 
75
- <?php foreach ($arrName as $name): ?>
79
+ <?php if (isset($arrName)) : ?>
76
80
 
77
- <?php echo h($name); ?>
81
+ <?php foreach ($arrName as $name): ?>
78
82
 
79
- <?php endforeach; ?>
83
+ <?php echo h($name); ?>
80
84
 
85
+ <?php endforeach; ?>
86
+
87
+ <?php endif; ?>
88
+
81
- </body>
89
+ </body>
82
90
 
83
91
  </html>
84
92
 

2

修正

2016/06/07 04:33

投稿

退会済みユーザー
test CHANGED
@@ -34,7 +34,11 @@
34
34
 
35
35
  // var_dump($file->fgetcsv()); // <- 確認用
36
36
 
37
+ //$arrName[] = $file->fgetcsv()[6];
38
+
37
- $arrName[] = $file->fgetcsv()[6];
39
+ $arrtmp = $file->fgetcsv();
40
+
41
+ $arrName[] = $arrtmp[6];
38
42
 
39
43
  }
40
44
 

1

修正

2016/06/07 03:40

投稿

退会済みユーザー
test CHANGED
@@ -26,7 +26,9 @@
26
26
 
27
27
  $file = new SplFileObject($tmp_name);
28
28
 
29
+ //$arrName = [];
30
+
29
- $arrName = [];
31
+ $arrName = array();
30
32
 
31
33
  while (!$file->eof()) {
32
34