Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
10php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu Kimiduka
10php
Commits
a5e14659
Commit
a5e14659
authored
Jul 08, 2016
by
君塚 悠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
プログラム作成(upload.php,upload_save.php:ファイルのアップロード)
parent
e7934b3b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
0 deletions
+92
-0
mail_input.php
php/php10/day04-1/mail_input.php
+0
-0
sendmail.php
php/php10/day04-1/sendmail.php
+14
-0
upload.php
php/php10/day04-2/upload.php
+16
-0
upload_save.php
php/php10/day04-2/upload_save.php
+62
-0
No files found.
php/php10/day04-
0
1/mail_input.php
→
php/php10/day04-1/mail_input.php
View file @
a5e14659
File moved
php/php10/day04-1/sendmail.php
0 → 100644
View file @
a5e14659
<?php
$header_info
=
"Form: "
.
$_POST
[
'_from'
]
.
"
\n
Content-Type: text/plain;carset
=ISO-2022-JP
\n
X-Mailer: PHP/"
.
phpversion
();
$body
=
"■■"
.
$_POST
[
'_subject'
]
.
"■■
\n\n
"
;
foreach
(
$_POST
as
$key
=>
$value
)
{
if
(
!
strstr
(
$key
,
"_"
))
{
$body
.=
"["
.
$key
.
"]"
.
$value
.
"
\r\n
"
;
}
}
mb_send_mail
(
$_POST
[
'_email'
],
$_POST
[
'_subject'
]
,
$body
,
$header_info
);
header
(
"Location: "
.
$_POST
[
'_result'
]);
?>
\ No newline at end of file
php/php10/day04-2/upload.php
0 → 100644
View file @
a5e14659
<html>
<head>
<title>
ファイルのアップロード
</title>
</head>
<body>
<h1
style=
"background:#cccccc"
>
ファイルのアップロード
</h1>
<form
method=
"post"
action=
"upload_save.php"
enctype=
"multpart/form-data"
>
<input
type=
"hidden"
name=
"max_file_size"
value=
1000000"
/>
<input
type=
"file"
name=
"upload_file size="
70
"
><br
/>
(上書き禁止)
<input
type=
"checkbox"
name=
"forbidden"
value=
"1"
checked
/>
<input
type=
"submit"
value=
"アップロード"
/>
</form>
</body>
</html>
\ No newline at end of file
php/php10/day04-2/upload_save.php
0 → 100644
View file @
a5e14659
<?php
$error_flag
=
FALSE
;
$name
=
"/\doc/"
.
$_FILES
[
'upload_file'
][
'name'
];
if
(
file_exists
(
$name
)
==
TRUE
&
$_POST
[
'forbidden'
]
==
1
)
{
$error_flag
=
TRUE
;
$error_msg
=
"同名のファイルが存在します。"
;
}
elseif
(
$_FILES
[
'upload_file'
][
'error'
]
!=
UPLOAD_ERR_OK
)
{
$error_flag
=
TRUE
;
switch
(
$_FILES
[
'upload'
][
'error'
])
{
case
UPLOAD_ER_FORM_SIZE
:
$error_msg
=
"php.iniのupload_max_filesize制限を越えています。"
;
break
;
case
UPLOAD_ERR_FORM_SIZE
:
$error_msg
=
"HTMLのMAX_FILE_SIZE制限を越えています。"
;
break
;
case
UPLOAD_ERR_PARTIAL
:
$error_msg
=
"ファイルが一部しかアップロードされていません。"
;
break
;
case
UPLOAD_ERR_NO_FILE
:
$error_msg
=
"ファイルはアップロードされていませんでした。"
;
break
;
default
:
$error_msg
=
"不明なエラーです。"
;
break
;
}
}
if
(
$error_flag
)
{
print
(
"<div style='color:Red;'>"
.
$error_msg
.
"</div>"
);
}
else
{
move_uploaded_file
(
$_FILES
[
'upload_file'
][
'tmp_name'
],
$name
);
}
?>
<html>
<head>
<title>
ファイルのアップロード
</title>
</head>
<body>
<h1
style=
"background:#cccccc"
>
ファイルアップロード(処理結果)
</h1>
<table
border=
"1"
>
<tr>
<th>
ファイル
</th><th>
サイズ
</th><th>
最終アクセス日
</th><th>
最終更新日
</th>
</tr>
<?php
clearstatcache
();
$o_dir
=
opendir
(
"./doc/"
);
while
(
$file
=
readdir
(
$o_dir
))
{
if
(
$file
!=
"."
&&
$file
!=
".."
)
{
?>
<tr>
<td><a
href=
"./doc/
<?php
print
(
$file
);
?>
"
>
<?php
print
(
$file
);
?>
</a></td>
<td>
<?php
print
(
round
(
filesize
(
"./doc/"
.
$file
)
/
1024
));
?>
KB
</td>
<td>
<?php
print
print
(
data
(
"Y/m/d H:i:s"
,
fileatime
(
"./doc/"
.
$file
)));
?>
</td>
<td>
<?php
print
print
(
data
(
"Y/m/d H:i:s"
,
filemtime
(
"./doc/"
.
$file
)));
?>
</td>
<tr>
<?php
}
}
closedir
(
$o_dir
);
?>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment