質問編集履歴
2
詳細
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,6 +13,10 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
ImageUploader.php
|
16
20
|
|
17
21
|
```php
|
18
22
|
|
@@ -76,4 +80,114 @@
|
|
76
80
|
|
77
81
|
```
|
78
82
|
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
index.php
|
88
|
+
|
89
|
+
```php
|
90
|
+
|
91
|
+
?php
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
ini_set('display_errors', 1);
|
96
|
+
|
97
|
+
define('MAX_FILE_SIZE', 1 * 1024 * 1024); // 1MB
|
98
|
+
|
99
|
+
define('THUMBNAIL_WIDTH', 400);
|
100
|
+
|
101
|
+
define('IMAGES_DIR', __DIR__ . '/images');
|
102
|
+
|
103
|
+
define('THUMBNAIL_DIR', __DIR__ . '/thumbs');
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
if (!function_exists('imagecreatetruecolor')) {
|
108
|
+
|
109
|
+
echo 'GD not installed';
|
110
|
+
|
111
|
+
exit;
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
function h($s) {
|
118
|
+
|
119
|
+
return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
require 'ImageUploader.php';
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
$uploader = new \MyApp\ImageUploader();
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
134
|
+
|
135
|
+
$uploader->upload();
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
?>
|
142
|
+
|
143
|
+
<!DOCTYPE html>
|
144
|
+
|
145
|
+
<html lang="ja">
|
146
|
+
|
147
|
+
<head>
|
148
|
+
|
149
|
+
<meta charset="utf-8">
|
150
|
+
|
151
|
+
<title>Image Uploader</title>
|
152
|
+
|
153
|
+
<style>
|
154
|
+
|
155
|
+
body {
|
156
|
+
|
157
|
+
text-align: center;
|
158
|
+
|
159
|
+
font-family: Arial, sans-serif;
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
</style>
|
164
|
+
|
165
|
+
</head>
|
166
|
+
|
167
|
+
<body>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<form action="" method="post" enctype="multipart/form-data">
|
172
|
+
|
173
|
+
<input type="hidden" name="MAX_FILE_SIZE" value="<?php h(MAX_FILE_SIZE); ?>">
|
174
|
+
|
175
|
+
<input type="file" name="image">
|
176
|
+
|
177
|
+
<input type="submit" value="upload">
|
178
|
+
|
179
|
+
</form>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</body>
|
184
|
+
|
185
|
+
</html>
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
79
193
|
[リンク内容](http://dotinstall.com/lessons/upload_image_php_v2/34605)
|
1
link
test
CHANGED
File without changes
|
test
CHANGED
@@ -75,3 +75,5 @@
|
|
75
75
|
|
76
76
|
|
77
77
|
```
|
78
|
+
|
79
|
+
[リンク内容](http://dotinstall.com/lessons/upload_image_php_v2/34605)
|