01.
<?
02.
require_once
(
"common.php"
);
03.
04.
require_once
(
"html_head.php"
);
05.
06.
print
"<pre>"
;
07.
print_r(
$_FILES
);
08.
print
"</pre>"
;
09.
10.
$target
=
$_FILES
[
'file_1'
][
'name'
];
11.
$_SESSION
[
'mime'
] =
$_FILES
[
'file_1'
][
'type'
];
12.
13.
$upload_dir
=
"./upload_file/"
;
14.
$upload
=
$upload_dir
;
15.
$upload
.=
$target
;
16.
print
$upload
.
"<br>"
;
17.
18.
if
( move_uploaded_file(
$_FILES
[
'file_1'
][
'tmp_name'
],
$upload
) ) {
19.
print
"アップロードに成功しました<br>"
;
20.
$_SESSION
[
"mail_file"
] =
$target
;
21.
print
"<script>"
;
22.
print
" parent.parent.$('#mail_file').val( \"{$target}\" );"
;
23.
print
"</script>"
;
24.
}
25.
else
{
26.
print
"アップロードに失敗しました<br>"
;
27.
}
28.
29.
30.
$dir_handle
= @opendir(
"./upload_file/"
);
31.
if
(
$dir_handle
) {
32.
$del_target
= readdir(
$dir_handle
);
33.
while
(
$del_target
!== false ) {
34.
35.
if
(
$del_target
!=
"."
&&
$del_target
!=
".."
) {
36.
print
"{$del_target} をチェックします<br>"
;
37.
$astamp
= stat(
$upload_dir
.
$del_target
);
38.
$laststamp
=
$astamp
[9];
39.
if
(
$laststamp
< time() - 300 ) {
40.
print
"{$del_target} を削除します<br>"
;
41.
unlink(
$upload_dir
.
$del_target
);
42.
}
43.
}
44.
$del_target
= readdir(
$dir_handle
);
45.
46.
}
47.
48.
closedir
(
$dir_handle
);
49.
}
50.
51.
print
"</body>"
;
52.
print
"</html>"
;
53.
?>