- 《Typecho如何设置伪静态》(2020年10月17日)
- 《短代码记录》(2020年10月17日)
- 《Access 访问统计》(2020年10月17日)
- 《Typecho评论邮件提醒插件》(2020年10月17日)
- 《typecho-Waxy网站添加鼠标点击特效》(2020年10月21日)
2020/10/17 新增下载站点阅读更多
html代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>KEKI.VIP</title>
</head>
<body>
<form action="https://xxx.wang/xxx/upload.php" method="post" enctype="multipart/form-data">
<label for="file">文件名:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="提交">
</form>
</body>
</html>
php代码
<?php
header("Content-Type:text/html;charset=utf8");
header("Access-Control-Allow-Origin: *"); //解决跨域
header('Access-Control-Allow-Methods:POST');// 响应类型
header("Content-Type:text/html;charset=utf8");
if ($_FILES["file"]["error"] > 0)
{
echo "错误:" . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "上传文件名: " . $_FILES["file"]["name"] . "<br>";
echo "文件类型: " . $_FILES["file"]["type"] . "<br>";
echo "文件大小: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; // 如果 upload 目录不存在该文件则将文件
// 判断当前目录下的 upload 目录是否存在该文件
// 如果没有 upload 目录,你需要创建它,upload 目录权限为 777
if (file_exists("./" . $_FILES["file"]["name"]))
{
echo "替换 " . "<br>";
unlink ( 'article_html.html' );
// 如果 upload 目录不存在该文件则将文件上传到 upload 目录下
move_uploaded_file($_FILES["file"]["tmp_name"], "./" . $_FILES["file"]["name"]);
echo "文件存储在: " . "./" . $_FILES["file"]["name"];
}
else
{
// 如果 upload 目录不存在该文件则将文件上传到 upload 目录下
move_uploaded_file($_FILES["file"]["tmp_name"], "./" . $_FILES["file"]["name"]);
echo "文件存储在: " . "./" . $_FILES["file"]["name"];
}
}
?>
<?php
/****************************
*** 功能:上传文件到服务器
****************************/
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>通过move_upload_file()函数上传文件到服务器</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="830" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><img src="images/bg_01.jpg" width="830" height="133" /></td>
</tr>
<form action="" method="post" enctype="multipart/form-data">
<tr>
<td width="193" rowspan="4"> <input type="hidden" name="MAX_FILE_SIZE" value="10000000000000" /></td>
<td width="423" height="50">选择上传文件:
<!--此语句可以显示一个按钮用来打开本地电脑---->
<input type="file" name="up_picture"/>
</td>
<td width="214" rowspan="4"> </td>
</tr>
<tr>
<td height="30" align="center"><span class="STYLE1">上传文件</span></td>
</tr>
<tr>
<td height="50" align="center"><input type="image" name="imageField2" src="images/bg_09.jpg" />
<input type="image" name="imageField3" src="images/bg_11.jpg" /></td>
</tr>
</form>
<tr>
<td height="70">
<?php
if(!empty($_FILES["up_picture"]["name"])){//判断上传内容是否为空
if($_FILES["up_picture"]["error"] > 0){//判断文件是否可以上传到服务器
echo "上传错误!";
switch($_FILES["up_picture"]["error"]){//如果上传错误 判断出错原因
case 1:
echo "上传文件大小超出配置文件规定值";
break;
case 2:
echo "上传文件大小超出表单中约定值";
break;
case 3:
echo "上传文件不全";
break;
case 4:
echo "没有上传文件";
break;
}
}else{
if(!is_dir("./upfile/")){//判断指定目录是否存在
mkdir("./upfile/");//创建一个目录
}
$path = './upfile/'.time().strstr($_FILES["up_picture"]["name"],'.');//定义文件名称和存储位置
if(is_uploaded_file($_FILES['up_picture']['tmp_name'])){//是否是HTTP POST上传
if(move_uploaded_file($_FILES['up_picture']['tmp_name'],$path)){//执行上传
echo "上传文件".$_FILES['up_picture']['name']."成功.文件大小为:".$_FILES['up_picture']['size'];
}else{
echo "上传失败";
}
}else{
echo "上传文件".$_FILES['up_picture']['name']."不合法";
}
}
}
?>
</td>
</tr>
<tr>
<td colspan="3"><img src="images/bg_14.jpg" width="830" height="30" /></td>
</tr>
</table>
</body>
</html>
This is a regular paragraph. |
<table>
<tr>
<td>This is a regular paragraph.</td>
</tr>
</table>
This is an H1
=============
This is an H2
-------------
Typecho和hexo,都使用 Markdown 作为其内容书写语法。
这是因为相较于富文本语法来说, Markdown 更加简洁,原始文件即使没有引擎解析仍然有很好的易读性。
最重要的是 Markdown 通过简单语法,让人们专注于文字书写。
Markdown 编写的文档后缀为 .md
或.markdown。
Markdown 标题
Markdown 通过 # + 空格 + 标题内容
的方式,来定义一个标题。
其中#
的多少表示这是第几级标题,最多可以有6级。
# 第一级标题
## 第二级标题
### 第三级标题
#### 第四级标题
##### 第五级标题
###### 第六级标题