我的表格中有这个:
<input type="file" name="images[]" multiple="multiple" />
然后这个 PHP 在表单的操作页面上:
$files = array();
$fdata = $_FILES["images"];
if(is_array($fdata["name"]))
{
//This is the problem
for ($i = 0; $i < count($fdata['name']); ++$i)
{
$files[] = array(
'name' => $fdata['name'][$i],
'tmp_name' => $fdata['tmp_name'][$i],
);
}
}
else
{
$files[] = $fdata;
}
foreach ($files as $file)
{
move_uploaded_file ( "$pic1_name","$image1") or die("image 1 did not copy<br>");
}
但我知道我的move_uploaded_file
线路错了。我需要在这里放什么?
更新:
我的最新代码如下:
$files = array();
$fdata = $_FILES["images"];
if(is_array($fdata["name"]))
{
//This is the problem
for ($i = 0; $i < count($fdata['name']); ++$i)
{
$files[] = array(
'name' => $fdata['name'][$i],
'tmp_name' => $fdata['tmp_name'][$i],
);
}
}
else
{
$files[] = $fdata;
}
foreach($_FILES['images'] as $file)
{
echo $file['tmp_name'];
move_uploaded_file($file['tmp_name'], $_SERVER["DOCUMENT_ROOT"].'/img/project-gallery/test');
}