<code><?php<br />//多文件上载系统完整版<br />include("../include/common.inc");<br />$title = "多个文件的上载程序";<br />include("../include/header.inc");<br />//定义允许上载文件的数目<br />define("UPLOAD_NO", 10);<br />echo("<p align='center'><font size='4' color='#000080'>欢迎您!<br>一次可以最多上载".UPLOAD_NO."个文件<br><HR>n");<br />if($REQUEST_METHOD!="POST"){<br />echo("<form enctype="multipart/form-data" method=post>n");<br />echo("<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="3000000">n");<br />for($i=1;$i<=UPLOAD_NO;$i++){<br />echo("<input type=file name=infile$i> ");<br />if($i%2==0)<br />echo("<br>n");<br />}<br />echo("<br><br><input type="checkbox" name="overload" value="ON"></font> <font color='#ff0000'>是否覆盖已经存在的文件?</font>");<br />echo("<br><br><input type=submit value=上载></form>n");<br />}<br />else{<br />//处理上载<br />$noinput = true;<br />for($i=1;$noinput&&($i<=UPLOAD_NO);$i++){<br />if(${"infile".$i}!="none") $noinput = false;<br />}<br />if($noinput){<br />echo("<font size='4' color='#000080'>没有选定的文件,返回重试</font>");<br />exit();<br />}<br />echo("<p align='center'><font size='4' color='#000080'>您选中的文件已经成功地上载到服务器的临时目录!</font><br>");<br />echo("<table border='1' width='84%' height='52' bordercolorlight='#008080' bordercolordark='#008080'><br /><tr><br /><td width='14%' bgcolor='#008000' height='21'><font color='#FFFFFF'>文件号</font></td><br /><td width='52%' bgcolor='#008000' height='21'><font color='#FFFFFF'>文件名称</font></td><br /><td width='34%' bgcolor='#008000' height='21'><font color='#FFFFFF'>文件大小</font></td><br /></tr>");<br />for($i=1;$i<=UPLOAD_NO;$i++){<br />$just=${"infile".$i."_size"};<br />$fp_size[i] = $just;<br />if($overload!=ON){<br />if(file_exists(AddSlashes(dirname($PATH_TRANSLATED))."upload".${"infile".$i."_name"}))<br />echo "<font size='4' color='#ff0000'>您上载的文件<font color='#000000'>".${"infile".$i."_name"}."</font>已经存在,该文件拷贝失败!</font><br>";<br />else{<br />if(${"infile".$i}!="none"&©(${"infile".$i},AddSlashes(dirname($PATH_TRANSLATED))."/upload/".${"infile".$i."_name"})&&unlink(${"infile".$i})){<br />$str = ${"infile".$i."_name"};<br />echo("<tr><br /><td width='14%' height='19'>$i</td><br /><td width='52%' height='19'>$str</td><br /><td width='34%' height='19'>$fp_size[i]</td><br /></tr>");<br />}<br />}<br />}<br />else{<br />if(${"infile".$i}!="none"&©(${"infile".$i},AddSlashes(dirname($PATH_TRANSLATED))."upload".${"infile".$i."_name"})&&unlink(${"infile".$i})){<br />$str = ${"infile".$i."_name"};<br />echo("<tr><br /><td width='14%' height='19'>$i</td><br /><td width='52%' height='19'>$str</td><br /><td width='34%' height='19'>$fp_size[i]</td><br /></tr>");<br />}<br />}<br />}<br />echo "</table>";<br />}<br />include("../include/footer.inc");<br />?></code>