简体   繁体   中英

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?

Why are oyu mixing usage of $_FILES and $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.

See move_uploaded_files() which has an example about handling multiple uploads.

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

Shouldn't it be

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

Rather than

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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