使用 PHP 上传 3(多个)文件 - 文件未保存在目标文件夹中
Uploading 3 (multiple) files with PHP - files are not getting saved in the target folder
上传文件的表单:
<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);}
?>
文件未保存,我收到用户定义的错误
在你的情况下,如果表格没有发送给你打印 `"Sorry ,could not upload!" 你的错误是在这行:
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);
}
?>
上传文件的表单:
<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);}
?>
文件未保存,我收到用户定义的错误
在你的情况下,如果表格没有发送给你打印 `"Sorry ,could not upload!" 你的错误是在这行:
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);
}
?>