0

我有一个包含 2 个文件输入字段的表单,但它只从输入字段上传一个文件(第一个文件“u_img”)。下面是输入字段

<input name="u_img" type="file" />
<input name="u_upload" type="file" />

我使用这个 php 上传它。

$pic_upload_path = "/home/users/A006193/fgpostbus.nl/www.fgpostbus.nl/enquete/";

// foto 1
if (is_uploaded_file($_FILES['u_upload']['tmp_name']))
{
$pic_loc_1 = $pic_upload_path.md5(time()).'_'.$_FILES['u_upload']['name'];
$rel_pic_loc_1 = "enquete/";
    if (move_uploaded_file($_FILES['u_upload']['tmp_name'],$pic_loc_1))
    {
    //echo "Het bestand is verplaatst naar $pic_loc1!";
    }
$rel_pic_loc_1 .= "".md5(time()).'_'.$_FILES['u_upload']['name']."";
}

if (is_uploaded_file($_FILES['u_img']['tmp_name']))
{
$pic_loc_2 = $pic_upload_path.md5(time()).'_'.$_FILES['u_img']['name'];
$rel_pic_loc_2 = "enquete/";
    if (move_uploaded_file($_FILES['u_img']['tmp_name'],$pic_loc_2))
    {
    //echo "Het bestand is verplaatst naar $pic_loc2!";
    }
$rel_pic_loc_2 .= "".md5(time()).'_'.$_FILES['u_img']['name']."";
}

我已经看这个很久了,我不明白为什么它不起作用。

添加:

结果来自 print_r($_FILES);

Array
(
[u_img] => Array
    (
        [name] => natasha.jpg
        [type] => image/jpeg
        [tmp_name] => /tmp/phpXU56Pg
        [error] => 0
        [size] => 5414
    )

[u_upload] => Array
    (
        [name] => DSC_0003.jpg
        [type] => image/jpeg
        [tmp_name] => /tmp/phpb4vAZj
        [error] => 0
        [size] => 110476
    )

)
4

0 回答 0