简体   繁体   English

文件上传PHP问题

[英]File upload PHP problem

Got this working 得到了这个工作

$i = 0;     
    foreach ($_FILES["image"]["error"] as $key => $error) {
        if ($error == UPLOAD_ERR_OK) {
            $tmp_name = $_FILES["image"]["tmp_name"][$key];
            $image_name = $_FILES["image"]["name"][$key];
            $image.$i = move_uploaded_file($tmp_name, "uploads/$image_name");
            $i ++;
        }
    }

I cant seem to get the directory storing into the variables $image# any ideas? 我似乎无法将目录存储到变量$ image#中有什么想法?

Why are oyu mixing usage of $_FILES and $HTTP_POST_FILES? 为什么oyu混合使用$ _FILES和$ HTTP_POST_FILES? Usage of the later suggests that you're using an old and outdated tutorial. 后面的用法表明您使用的是旧的和过时的教程。

You'RE also not checking whether multiple files have been successfully transefered and using copy() for this purpose is not encouraged. 您也不会检查是否已成功转换了多个文件,因此不建议为此使用copy()。

See move_uploaded_files() which has an example about handling multiple uploads. 请参阅move_uploaded_files() ,其中包含有关处理多个上载的示例。

最后,我通过创建一个数组并将这些值存储在该数组中来使其工作

Shouldn't it be 不是吗

$_FILES['image'][$i]['name']

Rather than 而不是

$_FILES['image']['name'][$i]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM