質問編集履歴

1

コードの追加

2016/07/05 09:20

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,12 +1,116 @@
1
+ >
2
+
1
- > Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\test.php on line 29
3
+ Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\test.php on line 28
2
4
 
3
5
 
4
6
 
5
7
  のエラーが出ます。
6
8
 
7
- 29行目はこれです。
8
9
 
9
10
 
11
+ ```php
12
+
13
+ <!DOCTYPE html>
14
+
15
+ <html>
16
+
17
+ <head>
18
+
19
+ </head>
20
+
21
+ <body>
22
+
23
+
24
+
25
+ <?php
26
+
27
+ if (isset($_FILES["upfile"])){
28
+
29
+ save_jpeg();
30
+
31
+ }else{
32
+
33
+ show_form();
34
+
35
+ }
36
+
37
+
38
+
39
+ function show_form() {
40
+
41
+ $self = $_SERVER["SCRIPT_NAME"];
42
+
43
+ $maxsize = 1024 * 1024 * 3;
44
+
45
+ echo <<< __FORM__
46
+
47
+ <form action="$self" method="POST" enctype="multipart/form-data">
48
+
49
+ upload jpeg data:<br/>
50
+
51
+ <input type="hidden" name="MAX_FILE_SIZE" value="$maxsize" />
52
+
53
+ <input type="file" name="upfile"><br/>
54
+
55
+ <input type="submit" value="Submit" />
56
+
57
+ </form>
58
+
59
+ __FORM__;
60
+
61
+ }
62
+
63
+
64
+
65
+ function save_jpeg() {
66
+
67
+ $tmp_file = $_FILES['upfile']['tmp_name'];
68
+
69
+ $save_file = dirname(__FILE__).'/test.jpeg';
70
+
71
+ if(!is_uploaded_file($tmp_file)){
72
+
73
+ echo "upload error";
74
+
75
+ exit;
76
+
77
+ }
78
+
79
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
80
+
81
+ $type = finfo_file($finfo,$tmp_file);
82
+
83
+ if($type != "image/jpeg"){
84
+
85
+ echo "not jpeg";
86
+
87
+ exit;
88
+
89
+ }
90
+
91
+ if (!move_uploaded_file($tmp_file, $save_file)){
92
+
93
+ echo "upload failed";
94
+
95
+ exit;
96
+
97
+ }
98
+
99
+ echo "<h1>uploaded jpeg</h1>";
100
+
101
+ echo "<img src='test.jpeg' />";
102
+
103
+ }
104
+
105
+ ?>
106
+
107
+ </body>
108
+
109
+ </html>
110
+
111
+ ```
112
+
113
+ 28行目はこれです。
10
114
 
11
115
  ```php
12
116