PHP Multiple File Array

前端 未结 6 1195
陌清茗
陌清茗 2020-12-03 09:29

I have the following code which works and uploads but it will not cycle through the array to upload every file, just the first file.

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 09:34

    it's easy to upload multiple files, follow these steps.

    1. use array notation means square brackets with the name of the input like this
    2. you can loop throught this using $_FILES Global Variable
        foreach ($_FILES['indtbl_logo']['tmp_name'] as $key => $tmp_name) {
            $file_name = $key . $_FILES['indtbl_logo']['name'][$key];
            $file_size = $_FILES['indtbl_logo']['size'][$key];
            $file_tmp = $_FILES['indtbl_logo']['tmp_name'][$key];
            $file_type = $_FILES['indtbl_logo']['type'][$key]; 
    
            echo $file_name;
            echo "
    "; }

提交回复
热议问题