上传文件的表格:
<form action="<?Php echo $_SERVER["PHP_SELF"];?>"method="post"enctype="multipart/form-data">
<input type="file"name="uf[]">
<input type="file"name="uf[]">
<input type="file"name="uf[]">
<input type="submit"value="upload"name="ok">
</form>
用于接收文件的PHP脚本:
<?php
if(!isset($_POST["ok"]))
{echo "Sorry ,could not upload!";}
else
{ $f1=$_FILES["uf"]["name"][0];
$f2=$_FILES["uf"]["name"][1]; $f3=$_FILES["uf"]["name"][2];
$path="path/";$filea=$path.$f1;
$fileb=$path.$f2;$filec=$path.$f3;
move_uploaded_file($_FILES["uf"][0]["tmp_name"],$filea);
move_uploaded_file($_FILES["uf"][1]["tmp_name"],$fileb);
move_uploaded_file($_FILES["uf"][0]["tmp_name"],$filec);}
?>
文件未保存,我收到用户定义的错误
答案 0 :(得分:1)
如果您的表格没有发送,请打印“抱歉,无法上传!”你的错误是这样的:
move_uploaded_file($_FILES["uf"][0]["tmp_name"],$filea);
move_uploaded_file($_FILES["uf"][1]["tmp_name"],$fileb);
move_uploaded_file($_FILES["uf"][0]["tmp_name"],$filec);
试试这个:
<?php
if(!isset($_POST["ok"]))
{echo "Sorry ,could not upload!";}
else
{
$f1=$_FILES["uf"]["name"][0];
$f2=$_FILES["uf"]["name"][1];
$f3=$_FILES["uf"]["name"][2];
$path="path/";
$filea=$path.$f1;
$fileb=$path.$f2;
$filec=$path.$f3;
move_uploaded_file($_FILES["uf"]["tmp_name"][0],$filea);
move_uploaded_file($_FILES["uf"]["tmp_name"][1],$fileb);
move_uploaded_file($_FILES["uf"]["tmp_name"][2],$filec);
}
?>