多文件上传的例子//upload_html.php---------------------------------------------------------------------------------------------
HTML
HEAD
TITLE上传文件/TITLE
/HEAD
script
function beforesubmit(forma)
{
var indexnamea=forma.indexname.value;
var upfilea=forma.upfile.value;
var k=/ /g;
var indexnamea=indexnamea.replace(k,"");
var upfilea=upfilea.replace(k,"");
if(indexnamea==""
upfilea=="")
{
alert("目录名称或上传的目录不能为空!");
return false;
}
return true;
}
/script
BODY BGCOLOR=WHITE
BR
form name=form1 action="upload.php" method=post enctype="multipart/form-data" n";
table cellspacing="1" cellpadding="5" width="580" bgcolor="#C2E2F5"
tr bgcolor="#E3F2FB" style="text-align:center"
td width="280" style="text-align:center" height="30"上传的文件/td
/tr
?
for($i=1;$i8;$i++)
{
$upfile="upfile".strval($i);
echo " trn";
echo " td bgcolor=#F5FBFE width=264input type=file name=$upfile lengh=25/tdn";
echo " /trn";
}
?
tr bgcolor="#E3F2FB"
td colspan="2" height="1"
/td
td colspan="2" height="1"
div style="text-align:center"
input type=submit name="submit" value=上传
/div
/td
/table
/form
/body/html
//-----------------------------------------------------------------------------------------------------------------------
//upload.php-------------------------------------------------------------------------------------------------------------
//upload_path:文件要上传到的目录路径
?php
for($i=1;$i8;$i++)
{
$upfile="upfile".strval($i);
if(chop($$indexname)!="" and chop($$upfile)!="")
{
$upfilename=($upfile."_name");
$filename=upload_path.$$upfilename;
$copyfile = copy($$upfile,$filename);
if (!$copyfile)
die("文件上传失败!");
$ls_file.=$$upfilename."n";
$flag=1 ;
}
}
if($flag){
$ls_msg="文件n".$ls_file."上传成功!";
}
else{
$ls_msg="无文件上传,请重新选择!";
}
echo "HTMLn" ;
echo "HEADn" ;
echo "/HEADn" ;
echo "BODY n" ;
echo $ls_msg."n";
echo "/BODYn" ;
echo "/HTMLn" ;
? 猜你喜欢