2

所以我正在尝试上传多个文件

我通过codeigniter中的SESSION变量控制用户上传的文件,方法是将会话变量设置为每次上传文件时保存文件名,并在可用时将其与以前的文件名合并,从而创建上传的文件数组由用户在单独的会话中。

这就是我所拥有的...

if (!$this->upload->do_upload("user_file")) {
           //I do stuff that handles the failure
        }else{
                $data = $this->upload->data();
                //
                //Grab the TEMP file
                $array[] = array('filename'=>$data['file_name']);

                //Add the temp file to the session

                if($this->session->userdata('uploaded_files')){
                    $temp_file = $this->session->userdata('uploaded_files');
                    $this->session->set_userdata('uploaded_files',array_merge($array,$temp_file));

                }else{
                    //no need to merge since its the first one
                    $this->session->set_userdata('uploaded_files',$array);
                }
        } 

我的问题是当 PHP 同时收到多个请求时,它只处理队列中的第一个请求 只在终点线拿一个

当我一次给它一个请求时,它需要所有的请求 带走所有这些

所以我不能保证文件将在不同的时间完成上传,errrm ...我怎样才能让我的数组在不考虑完成时间的情况下上传所有文件名,也许使用会话不是一个好方法?

PS:在服务器端,我的所有文件都在那里,包括那些没有进入上传文件数组的文件

4

1 回答 1

0

您可以使用'name' 索引从$_FILES 变量中检索文件名(例如$_FILES['myfile1']['name'])。

于 2014-11-10T15:34:32.920 回答