实现文件上传的程序源码

时间:2010-01-11 08:16:06   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:间默认时间为 30s,设置为0时为不限时 */set_time_limit($TimeLimit);If(($Upfile != "none")&&($Upfile != "")){$Filepath="d:/web/web/php/test"; //上载文件存放路径$FileName=$Filepath.$Upfile_name;if($Upfile_size <1024) //上载文件大小{$FileSize = (string)$Upfile_size . "字节";}elseif($Upfile_size <(1024 * 1024))...
  正文:

<HTML>
<HEAD>
<TITLE>文件上传界面</TITLE>
</HEAD>
<BODY><TABLE><CENTER>
<?
if($UploadAction){
$UploadAction=0;
$TimeLimit=60;
/*设置超时限制时间默认时间为 30s,设置为0时为不限时 */
set_time_limit($TimeLimit);
If(($Upfile != "none")&&
($Upfile != ""))
{
$Filepath="d:/web/web/PHP/test"; //上载文件存放路径
$FileName=$Filepath.$Upfile_name;
if($Upfile_size <1024) //上载文件大小
{$FileSize = (string)$Upfile_size . "字节";}
elseif($Upfile_size <(1024 * 1024))
{
$FileSize = number_format((double)($Upfile_size / 1024), 1) . " KB";
}
else
{
$FileSize = number_format((double)($Upfile_size/(1024*1024)),1)."MB";
}
if(!file_exists($FileName))
{
if(copy($Upfile,$FileName))
{unlink($Upfile);
echo "<br><br>/n";
echo "文件 $Upfile_name 已上载成功!";
echo "<br><br>/n";
echo "文件位置:$FileName";
echo "<br><br>/n";
echo "文件大小:$FileSize";
echo "<br><br>/n";
}
else
{echo "文件 $Upfile_name上载失败!"; }
}
else
{echo "文件 $Upfile_name已经存在!"; }
}
else
{echo "你没有选择任何文件上载!"; }
set_time_limit(30); //恢复默认超时设置
}
?>
<FORM ENCTYPE = "multipart/form-data" NAME = "SubmitForm"
ACTION = "default.php" METHOD = "POST">
<INPUT TYPE = "hidden" NAME = "MAX_FILE_SIZE" VALUE ="1000000">
<INPUT TYPE = "hidden" NAME = "UploadAction" VALUE = "1">
<TR><TD><INPUT NAME = "Upfile" TYPE = "file" SIZE = "30"></TD>
</TR><TR><TD><INPUT NAME = "submit" VALUE = "提交" TYPE = "submit">
<INPUT NAME = "reset" VALUE = "重置" TYPE = "reset"></TD>
</TR></FORM></CENTER></TABLE>
</BODY>
</HTML>


来源:http://www.002pc.com/master/College/Programming/PHP/11719.html

收藏到:

关于《实现文件上传的程序源码》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td