| 導購 | 订阅 | 在线投稿
分享
 
 
 

實現文件上傳的程序源碼

來源:互聯網  2008-12-28 07:39:23  評論

<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>

<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>
󰈣󰈤
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
王朝網路微信公眾號
微信掃碼關註本站公眾號 wangchaonetcn
 
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有