|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
培训的第一阶段,学习的是HTML/CSS/JavaScript基础。 若何完成文件上传?
以下为援用的内容:
<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有兴趣,那么选择教材也是很重要的。 |
|