<body>
<form enctype="multipart/form-data" method=post action=putpic.php>
<input type=hidden name=action value=put>
<input type=file name=upload>
<input type=submit value=UploadFile>
</form>
<form method=post action=putpic.php>
<input type=hidden name=action value=del>
<input type=text name=delfile>
<input type=submit value=DeleteFile>
</form>
<form method=post action=putpic.php>
<input type=hidden name=action value=list>
<input type=submit value=ListFile>
</form>
<?
switch ($action) {
case "put":
# /tmp not allow at f2s.com
$copypath =".";
echo "File size : $upload_size byte<br>";
if ($upload <> "none" and $upload_size < 10000) {
copy ($upload,"$copypath/$upload_name");
} else {
echo "File require and less than 10000 byte";
}
break;
case "del":
if (file_exists($delfile)) {
echo "Found : $delfile<br>";
$l4 = strtolower(substr($delfile,-4));
if ($l4 == ".jpg" or $l4 == ".gif") {
unlink($delfile);
}
$fn = preg_split("/[.]/",$delfile);
$delftxt = $fn[0].".txt";
if (file_exists($delftxt)) { unlink($delftxt); }
if (file_exists($delfile)) { echo "Delete $delfile : Error"; }
} else {
echo "File not found";
}
break;
case "list":
$dir=".";
$dir_handle = opendir($dir);
while ($list = readdir($dir_handle)) {
$l4 = strtolower(substr($list,-4));
if ($l4 == ".jpg" or $l4 == ".gif") {
echo "<img src=$list> $list";
echo " Date: ".date("F d, Y",fileatime("$list"));
echo " Size: ".filesize("$list")." byte<br>";
}
}
break;
}
?>
จำนวน : 56 บรรทัด