質問編集履歴
2
コードだけの提示に変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,38 +80,38 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
-
|
83
|
+
?>
|
84
84
|
|
85
|
-
|
85
|
+
<!DOCTYPE html>
|
86
86
|
|
87
|
-
|
87
|
+
<html lang="ja">
|
88
88
|
|
89
|
-
|
89
|
+
<head>
|
90
90
|
|
91
|
-
|
91
|
+
<meta charset="utf-8">
|
92
92
|
|
93
|
-
|
93
|
+
<title></title>
|
94
94
|
|
95
|
-
|
95
|
+
</head>
|
96
96
|
|
97
|
-
|
97
|
+
<body>
|
98
98
|
|
99
|
-
|
99
|
+
<form action='' method='POST' enctype='multipart/form-data'>
|
100
100
|
|
101
|
-
|
101
|
+
プロフィール画像<input type='file' name='image'>
|
102
102
|
|
103
|
-
|
103
|
+
<?php if (!empty($errors['image'])): ?>
|
104
104
|
|
105
|
-
|
105
|
+
<p><?php echo $errors['image']; ?></p>
|
106
106
|
|
107
|
-
|
107
|
+
<?php endif; ?>
|
108
108
|
|
109
|
-
|
109
|
+
<input type='submit' value='送信'>
|
110
110
|
|
111
|
-
|
111
|
+
</form>
|
112
112
|
|
113
|
-
|
113
|
+
</body>
|
114
114
|
|
115
|
-
|
115
|
+
</html>
|
116
116
|
|
117
117
|
```
|
1
コードだけ提示いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,55 +30,55 @@
|
|
30
30
|
|
31
31
|
```ここに言語を入力
|
32
32
|
|
33
|
-
|
33
|
+
<?php
|
34
34
|
|
35
|
-
|
35
|
+
session_start();
|
36
36
|
|
37
|
-
|
37
|
+
if (!empty($_POST)) {
|
38
38
|
|
39
|
-
|
39
|
+
^ $errors = [];
|
40
40
|
|
41
|
-
|
41
|
+
^ if (!empty($_FILES['image']['name'])) {
|
42
42
|
|
43
|
-
|
43
|
+
^ ^ $type = exif_imagetype($_FILES['image']['tmp_name']);
|
44
44
|
|
45
|
-
|
45
|
+
^ ^ if (!isset($_FILES['image']['error']) || !is_int($_FILES['image']['error'])) {
|
46
46
|
|
47
|
-
|
47
|
+
^ ^ ^ $errors['image'] = 'アップロードできません';
|
48
48
|
|
49
|
-
|
49
|
+
^ ^ } elseif ($_FILES['image']['errors'] > 0) {
|
50
50
|
|
51
|
-
|
51
|
+
^ ^ ^ $errors['image'] = 'アップロードできませんでした。';
|
52
52
|
|
53
|
-
|
53
|
+
^ ^ } elseif (!in_array($type, [IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_GIF], true)) {
|
54
54
|
|
55
|
-
|
55
|
+
^ ^ ^ $errors['image'] = '画像ファイルではありません';
|
56
56
|
|
57
|
-
|
57
|
+
^ ^ } else {
|
58
58
|
|
59
|
-
|
59
|
+
^ ^ ^ $image = sha1_file($_FILES['image']['tmp_name']);
|
60
60
|
|
61
|
-
|
61
|
+
^ ^ ^ $image .= '.' . substr($_FILES['image']['name'], -3);
|
62
62
|
|
63
|
-
|
63
|
+
^ ^ ^ move_uploaded_file($_FILES['image']['tmp_name'], './pictures/' . $image);
|
64
64
|
|
65
|
-
|
65
|
+
^ ^ }
|
66
66
|
|
67
|
-
|
67
|
+
^ }
|
68
68
|
|
69
|
-
|
69
|
+
^ if (empty($errors)) {
|
70
70
|
|
71
|
-
|
71
|
+
^ ^ $_SESSION['image'] = $image;
|
72
72
|
|
73
|
-
|
73
|
+
^ ^ header('Location: check.php');
|
74
74
|
|
75
|
-
|
75
|
+
^ ^ exit();
|
76
76
|
|
77
|
-
|
77
|
+
^ }
|
78
78
|
|
79
|
-
|
79
|
+
}
|
80
80
|
|
81
|
-
|
81
|
+
|
82
82
|
|
83
83
|
26 ?>
|
84
84
|
|