Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/2/17 7:33:04
PHP实例:实现文件上传的程序源码_[PHP教程]

PHP实例:实现文件上传的程序源码_[PHP教程]

如何实现文件上传 ?




文件上传界面


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 "
\n";
echo "文件 Upfile_name 已上载成功!";
echo "
\n";
echo "文件位置:FileName";
echo "
\n";
echo "文件大小:FileSize";
echo "
\n";
}
else
{echo "文件 Upfile_name上载失败!"; }
}
else
{echo "文件 Upfile_name已经存在!"; }
}
else
{echo "你没有选择任何文件上载!"; }
set_time_limit(30); //恢复默认超时设置
}
?>
ACTION = "default.php" METHOD = "POST">













If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759