求一个文件上传和管理的程序 http://down.chinaz.com/class/54_2.htm这里面源码不少,你可以自己选个合适的看看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个是上传的代码: <table width="100%" border="0" cellpadding="3px" cellspacing="1px" align="center"> <tr> <td height="25" class=head>文件管理</td> </tr> <tr> <td> <?php require("config.php"); if(isset($_POST["name"])) { $name=$_POST["name"]; $date = date("U"); $filedir="../File/"; $fileName_tmp=md5($fileName_name); switch($fileName_type) { case "application/msword": $fileextname = "doc"; break; case "application/vnd.ms-excel": $fileextname = "xls"; break; case "application/octet-stream": $fileextname = "rar"; break; case "application/x-zip-compressed": $fileextname = "zip"; break; case "application/msaccess": $fileextname = "mdb"; break; case "application/vnd.ms-powerpoint": $fileextname = "ppt"; break; case "image/pjpeg": $fileextname = "jpg"; break; case "image/gif": $fileextname = "gif"; break; case "image/x-png": $fileextname = "png"; break; case "application/x-shockwave-flash": $fileextname = "swf"; break; case "text/plain": $fileextname = "txt"; break; } $md5_fileName=$fileName_tmp.".".$fileextname; $sql= "insert into Files(name,fileName,date) values ('$name','$md5_fileName','$date')"; $isR=mysql_query($sql); if(true) { copy($fileName,$filedir.$fileName_tmp.".".$fileextname); echo "上传成功!"; } else { echo "上传失败"; } } else { ?> <table width="98%" border="0" cellpadding="5px" align="center"> <tr> <td> </td> </tr> </table> <table width="98%" border="0" cellspacing="1px" cellpadding="5px" bgcolor="#B26600" align="center"> <tr> <td align="center" class="head" colspan=2>上传文件</td> </tr><script language="JavaScript" src="images/post.js"></script><form method=post action=fileUpLoad.php name=FORM enctype="multipart/form-data"> <tr bgcolor="#FFFFFF"> <td width="25%">在网页上显示的文件名: </td><td><input type="text" name="name" size="30"></td> </tr> <tr bgcolor="#FFFFFF"> <td width="25%">上传文件:</td> <td> <input type="file" name="fileName" id="fileName" /></td> <tr bgcolor="#FFFFFF"> <td align="center" class="head" colspan="2"><input type='submit' name='sub' value='提交'> </td></tr> </form> </table> </td> </tr> </table></td> </tr></table><?php }?> 这个是管理代码:<table width="100%" border="0" cellpadding="3px" cellspacing="1px" align="center"><tr><td height="25" class=head>文件管理</td></tr><tr><td><?phprequire("config.php");function delete_file($file){$delete = @unlink($file);clearstatcache();if(@file_exists($file)){$filesys = eregi_replace("/","//",$file);$delete = @system("del $filesys");clearstatcache();if(@file_exists($file)){$delete = @chmod ($file, 0777);$delete = @unlink($file);$delete = @system("del $filesys");}}clearstatcache();if(@file_exists($file)){return false;}else{return true;}}if(isset($_GET["name"])){$name=$_GET["name"];$sql= "delete from Files where fileName='".$name."'";$isR=mysql_query($sql);if(isR){$path="../File/".$name;delete_file($path); echo "删除成功!";}else{echo "删除失败!";}}else{?><table width="98%" border="0" cellpadding="5px" align="center"><tr><td> </td></tr></table><table width="98%" border="0" cellspacing="1px" cellpadding="5px" bgcolor="#B26600" align="center"><tr><td align="center" class="head" colspan=2>上传文件</td></tr><script language="JavaScript" src="images/post.js"></script><tr bgcolor="#FFFFFF"><td align="center"><table width="496" align="center"><tbody><?php$sql="select * from Files";$result=mysql_query($sql);$total=mysql_num_rows($result);$PageSize=20;$TotalRows=$total;//总共有多少记录$TotalPages=ceil($TotalRows/$PageSize);//总共有多少页$Rowstring="<br />"."共有 ".$TotalPages." 页";if(isset($_GET["Page"])){$Page=intval($_GET["Page"]);}else{$Page=1;}$CurrentLocation.=$_SERVER["PHP_SELF"];$Pagestring="";switch($Page){case $TotalRows<=$PageSize:$Pagestring.="";break;case $Page==1:for($i=1;$i<=$TotalPages;$i=$i+1){if($i==$Page)$Pagestring.="<a href=?Page=$i><font color='red'> $i</font></a>";else$Pagestring.="<a href=?Page=$i> $i </a>";}$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page+1).">下一页</a>";break;case $Page==$TotalPages:$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page-1).">上一页 </a>";for($i=1;$i<=$TotalPages;$i=$i+1){if($i==$Page)$Pagestring.="<a href=?Page=$i><font color='red'> $i</font></a>";else$Pagestring.="<a href=?Page=$i> $i </a>";}break;case $Page>1:$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page-1).">上一页 </a>";for($i=1;$i<=$TotalPages;$i=$i+1){if($i==$Page)$Pagestring.="<a href=?Page=$i><font color='red'> $i</font></a>";else{//$Pagestring.="<a href=?Page=$i> $i </a>";if($i==$TotalPages)$Pagestring.="<a href=?Page=$i> $i </a>"."<a href=".$CurrentLocation."?Page=".($Page+1).">下一页</a>";else$Pagestring.="<a href=?Page=$i> $i </a>";}}//$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page+1)."下一页 </a>";break;case $Page<0||$Page>$TotalPages:$Pagestring.="Please do not attend to crack the php page.";break;}$sql="select * from "."Files order by date desc"." limit ".($Page-1)*$PageSize.",".$PageSize;$result=mysql_query($sql);while($row=mysql_fetch_row($result)){//$id=$row[0];?><tr><td width="97%"><?php$da1=date("Y-m-d",$row[2]); echo "[$da1]";echo $row[1];?> <a href="editFile.php?name=<?php echo $row[3];?>" onclick="return confirm('\n确认要删除么?')">【删除】</a><?php?></td></tr><?php }?></tbody></table></td></tr> </table> </td></tr></table></td></tr></table><?php }?> php验证码问题 php 对接联通短信接口 参数传递问题 excel两个表中中文字段匹配不成功 swfupload上传控件手机chrome浏览器无法浏览文件 php 函数 如何知道PHP.EXE的版本 PHP中替换字符串中的<>然后在文本框中显示 editplus的文件搜索怎么用? 请问一个关于数组的简单问题 php 函数速度问题,在线给分! PDO操作mssql的image字段
<table width="100%" border="0" cellpadding="3px" cellspacing="1px" align="center">
<tr>
<td height="25" class=head>文件管理</td>
</tr>
<tr>
<td>
<?php
require("config.php");
if(isset($_POST["name"]))
{
$name=$_POST["name"];
$date = date("U");
$filedir="../File/";
$fileName_tmp=md5($fileName_name);
switch($fileName_type)
{
case "application/msword":
$fileextname = "doc";
break;
case "application/vnd.ms-excel":
$fileextname = "xls";
break;
case "application/octet-stream":
$fileextname = "rar";
break;
case "application/x-zip-compressed":
$fileextname = "zip";
break;
case "application/msaccess":
$fileextname = "mdb";
break;
case "application/vnd.ms-powerpoint":
$fileextname = "ppt";
break;
case "image/pjpeg":
$fileextname = "jpg";
break;
case "image/gif":
$fileextname = "gif";
break;
case "image/x-png":
$fileextname = "png";
break;
case "application/x-shockwave-flash":
$fileextname = "swf";
break;
case "text/plain":
$fileextname = "txt";
break;
}
$md5_fileName=$fileName_tmp.".".$fileextname;
$sql= "insert into Files(name,fileName,date) values ('$name','$md5_fileName','$date')";
$isR=mysql_query($sql);
if(true)
{
copy($fileName,$filedir.$fileName_tmp.".".$fileextname);
echo "上传成功!";
}
else
{
echo "上传失败";
}
}
else
{
?>
<table width="98%" border="0" cellpadding="5px" align="center">
<tr>
<td> </td>
</tr>
</table>
<table width="98%" border="0" cellspacing="1px" cellpadding="5px" bgcolor="#B26600" align="center">
<tr>
<td align="center" class="head" colspan=2>上传文件</td>
</tr><script language="JavaScript" src="images/post.js"></script>
<form method=post action=fileUpLoad.php name=FORM enctype="multipart/form-data">
<tr bgcolor="#FFFFFF">
<td width="25%">在网页上显示的文件名:
</td><td><input type="text" name="name" size="30"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="25%">上传文件:</td>
<td>
<input type="file" name="fileName" id="fileName" /></td>
<tr bgcolor="#FFFFFF">
<td align="center" class="head" colspan="2"><input type='submit' name='sub' value='提交'> </td></tr>
</form>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
<?php }?>
<tr>
<td height="25" class=head>文件管理</td>
</tr>
<tr>
<td>
<?php
require("config.php");
function delete_file($file){
$delete = @unlink($file);
clearstatcache();
if(@file_exists($file)){
$filesys = eregi_replace("/","//",$file);
$delete = @system("del $filesys");
clearstatcache();
if(@file_exists($file)){
$delete = @chmod ($file, 0777);
$delete = @unlink($file);
$delete = @system("del $filesys");
}
}
clearstatcache();
if(@file_exists($file)){
return false;
}else{
return true;
}
}
if(isset($_GET["name"]))
{
$name=$_GET["name"];
$sql= "delete from Files where fileName='".$name."'";
$isR=mysql_query($sql);
if(isR)
{
$path="../File/".$name;
delete_file($path);
echo "删除成功!";
}
else
{
echo "删除失败!";
}
}
else
{
?>
<table width="98%" border="0" cellpadding="5px" align="center">
<tr>
<td> </td>
</tr>
</table>
<table width="98%" border="0" cellspacing="1px" cellpadding="5px" bgcolor="#B26600" align="center">
<tr>
<td align="center" class="head" colspan=2>上传文件</td>
</tr><script language="JavaScript" src="images/post.js"></script>
<tr bgcolor="#FFFFFF">
<td align="center">
<table width="496" align="center">
<tbody>
<?php
$sql="select * from Files";
$result=mysql_query($sql);
$total=mysql_num_rows($result);
$PageSize=20;
$TotalRows=$total;//总共有多少记录
$TotalPages=ceil($TotalRows/$PageSize);//总共有多少页
$Rowstring="<br />"."共有 ".$TotalPages." 页";if(isset($_GET["Page"]))
{
$Page=intval($_GET["Page"]);
}
else
{
$Page=1;
}
$CurrentLocation.=$_SERVER["PHP_SELF"];$Pagestring="";
switch($Page)
{
case $TotalRows<=$PageSize:
$Pagestring.="";
break;
case $Page==1:
for($i=1;$i<=$TotalPages;$i=$i+1)
{
if($i==$Page)
$Pagestring.="<a href=?Page=$i><font color='red'> $i</font></a>";
else
$Pagestring.="<a href=?Page=$i> $i </a>";
}
$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page+1).">下一页</a>";
break;
case $Page==$TotalPages:
$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page-1).">上一页 </a>";
for($i=1;$i<=$TotalPages;$i=$i+1)
{
if($i==$Page)
$Pagestring.="<a href=?Page=$i><font color='red'> $i</font></a>";
else
$Pagestring.="<a href=?Page=$i> $i </a>";
}
break;
case $Page>1:
$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page-1).">上一页 </a>";
for($i=1;$i<=$TotalPages;$i=$i+1)
{
if($i==$Page)
$Pagestring.="<a href=?Page=$i><font color='red'> $i</font></a>";
else
{
//$Pagestring.="<a href=?Page=$i> $i </a>";
if($i==$TotalPages)
$Pagestring.="<a href=?Page=$i> $i </a>"."<a href=".$CurrentLocation."?Page=".($Page+1).">下一页</a>";
else
$Pagestring.="<a href=?Page=$i> $i </a>";
}
}
//$Pagestring.="<a href=".$CurrentLocation."?Page=".($Page+1)."下一页 </a>";
break;
case $Page<0||$Page>$TotalPages:
$Pagestring.="Please do not attend to crack the php page.";
break;
}
$sql="select * from "."Files order by date desc"." limit ".($Page-1)*$PageSize.",".$PageSize;
$result=mysql_query($sql);
while($row=mysql_fetch_row($result))
{
//$id=$row[0];
?>
<tr>
<td width="97%">
<?php
$da1=date("Y-m-d",$row[2]);
echo "[$da1]";
echo $row[1];
?>
<a href="editFile.php?name=<?php echo $row[3];?>" onclick="return confirm('\n确认要删除么?')">
【删除】
</a>
<?php
?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
<?php }?>