如何实现文件上传的程序源码_PHP教程
教程Tag:暂无Tag,欢迎添加,赚取U币!
推荐:常用的数值判断函数常用的对象类型判断 HTML HEAD TITLE常用的数值判断函数/TITLE /HEAD BODY ? //判断数组 colors = array(red, blue, green); if(is_array(colors)) { print(colors is an array.br); } //双精度数判断 Temperature = 15.23; if(is_double(Temperatu
如何实现文件上传 ?
<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>
<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>
分享:详解PHP中缓存技术的应用PHP,一门最近几年兴起的web设计脚本语言,由于它的强大和可伸缩性,近几年来得到长足的发展,php相比传统的asp网站,在速度上有绝对的优势,想mssql转6万条数据php如需要40秒,asp不下2分钟.但是,由于网站的数据越来越多,我们渴求能更快速的调用数据,不必要每次都
相关PHP教程:
- 相关链接:
- 教程说明:
PHP教程-如何实现文件上传的程序源码。