最好使用$_FILES数组.
/////////////////////////////////////////////////////
<?php
class image
{
function uploadFiles($up,$upload)
{
$minSize=1;
$maxSize=2000000;
$imagePath="./";
if(!$up['size']<$minSize && !$upload['size']<$minSize)
{
if($up['size'] >$maxSize && $upload['size']>$maxSize)
{
echo "<script language=javascript >window.alert(\"文件太大!请您压缩或分次发送!\");</script>";
return false;//返回值
} else {
$upfile = $imagePath.$up['name'];
$uploadfile = $imagePath.$upload['name'];
if( copy($up['tmp_name'],$upfile) && copy($upload['tmp_name'],$uploadfile))
{
echo "<script language=javascript >window.alert(\"文件成功上传!!\");window.history.back();</script>";
return true;//返回值
}else{
echo "<script language=javascript >window.alert(\"文件失败上传!!\");window.history.back();</script>";
return false;//返回值
}
}
}
}
}
?>
<?
$image = new image;
if($_POST['submit'])
{
if($image->uploadFiles($_FILES['up'],$_FILES['upload']))
echo "asd";
else
echo "lose";
}
?>
<form method="post" enctype="multipart/form-data" name="form1">
<input name="up" type="file"><br>
<input name="upload" type="file">
<br/><input type="submit" name=submit value="提交">
<input name="reset" type="reset" id="reset" value="重置"></form>
/////////////////////////////////////////////////////
<?php
class image
{
function uploadFiles($up,$upload)
{
$minSize=1;
$maxSize=2000000;
$imagePath="./";
if(!$up['size']<$minSize && !$upload['size']<$minSize)
{
if($up['size'] >$maxSize && $upload['size']>$maxSize)
{
echo "<script language=javascript >window.alert(\"文件太大!请您压缩或分次发送!\");</script>";
return false;//返回值
} else {
$upfile = $imagePath.$up['name'];
$uploadfile = $imagePath.$upload['name'];
if( copy($up['tmp_name'],$upfile) && copy($upload['tmp_name'],$uploadfile))
{
echo "<script language=javascript >window.alert(\"文件成功上传!!\");window.history.back();</script>";
return true;//返回值
}else{
echo "<script language=javascript >window.alert(\"文件失败上传!!\");window.history.back();</script>";
return false;//返回值
}
}
}
}
}
?>
<?
$image = new image;
if($_POST['submit'])
{
if($image->uploadFiles($_FILES['up'],$_FILES['upload']))
echo "asd";
else
echo "lose";
}
?>
<form method="post" enctype="multipart/form-data" name="form1">
<input name="up" type="file"><br>
<input name="upload" type="file">
<br/><input type="submit" name=submit value="提交">
<input name="reset" type="reset" id="reset" value="重置"></form>
window.history.back();