这是我的表单页面的代码
<form action="gallerycontroller.php" method="post" enctype="multipart/form-data">
<div>
<label class="desc" id="title4" for="Field4">
Message
</label>
<div>
<textarea id="reply" name="name" spellcheck="true" rows="10" cols="50" tabindex="4"></textarea>
<!-- Custom icons with callback -->
<input type="file" name="file">
</div>
</div>
<div>
<div>
<div>
<input id="saveForm" name="saveForm" type="submit" value="Save">
</div>
</div>
这是gallerycontroller页面
<?php
include("model.php");
$db = new database;
$name = $_POST['name'];
$file = $_FILES['file'];
$filename = $file['name'];
$filetmp = $file['tmp_name'];
$file_ext = explode('.',$filename);
$file_ext = strtolower(end($file_ext));
$file_name_new = uniqid('',true) .'.'. $file_ext;
$file_destination = 'file/' .$file_name_new;
move_uploaded_file($filetmp, $file_destination);
$designation=$_POST['principal'];
$r=$db->insert($name,$file_destination);
if($r>0)
{
header("Location:upload.php?reply='sucess'");
}
else
{
header("Location:upload.php?reply='fail'");
}
?>
但我想一次上传多个文件,这个单个文件上传代码工作正常。如果可能,请将此代码转换为多文件上传,否则请参考新代码。
答案 0 :(得分:0)
使用&#34;多个&#34;文件的属性
pg_restore: [tar archiver] could not find header for file "toc.dat" in tar archive
然后在php中使用for循环
<input type="file" name="img[]" multiple>