没有合适的资源?快使用搜索试试~ 我知道了~
本文实例为大家分享了PHP实现文件上传与下载的具体代码,供大家参考,具体内容如下 主页index.php <html> <head> <title>图片操作</title> <style> #contains { width: 500px; margin: 0 auto; text-align: center; color: #0F0; } th { background: #ccc; } td { width: 150px; height: 50px; text-align: center; } </style> </head> <body> <div id
资源详情
资源评论
资源推荐
PHP实现文件上传与下载实现文件上传与下载
本文实例为大家分享了PHP实现文件上传与下载的具体代码,供大家参考,具体内容如下
主页index.php
<html>
<head>
<title>图片操作</title>
<style>
#contains {
width: 500px;
margin: 0 auto;
text-align: center;
color: #0F0;
}
th {
background: #ccc;
}
td {
width: 150px;
height: 50px;
text-align: center;
}
</style>
</head>
<body>
<div id="contains">
<h2>图片上传和下载</h2>
<!----------------文件上传表单------------->
<form action="doupload.php" method="post" enctype="multipart/form-data">
<input type="hidden" value="10000000" /> <!---避免上传后发现文件过大--->
<input type="file" name="pic"/>
<input type="submit" value="上传"/>
</form>
<!--------------------------------------->
<table width="500" border="0">
<tr>
<th>序号</th><th>图片</th><th>添加时间</th><th>操作</th>
</tr>
<?php
//1.打开目录
$dir = opendir("./imgs");
//2.遍历目录
$i = 0;
$color = "#ff0";
while ($f = readdir($dir)){ //$f代表这每个文件的名字
if ($f == '.' || $f == "..") continue; //处理特殊隐藏的文件
$i++;
if ($i % 2 == 0) $color = "#ccc";
else $color = "#ffa";
echo "<tr bgcolor=$color>";
echo "<td>{$i}</td>";
echo "<td><img src='./imgs/{$f}' width='150' height='50'/></td>";
echo "<td>".date("Y-m-d", filectime('./imgs/'.$f))."</td>";
echo "<td><a href='./imgs/{$f}'>查看</a>
<a href='download.php?name={$f}'>下载</a></td>";
echo "</tr>";
// echo $f." ";
}
?>
</table>
</div>
</body>
</html>
上传doupload.php
<?php
weixin_38669832
- 粉丝: 5
- 资源: 957
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0