我試圖從一個輸入一次上傳多個文件:笨 - 上傳多個文件與一個輸入
<input type="file" name="form-image[]" id="form-image" multiple="true" />
而本身沒有CodeIgniter工作正常。在我嘗試使用CodeIgniterrs文件助手做同樣的事情時,我得到一個錯誤(is_uploaded_file() expects parameter 1 to be string, array given),這表明我做錯了什麼,或者CodeIgniter只是不支持多個文件?
我的錯誤代碼至今:
//Iterate through each file uploaded
for ($i = 0; isset($_FILES['form-image']['name'][$i]); $i++) {
//Fix the settings
$config['upload_path'] = "./static/vimmel/";
$config['file_name'] = time() . rand(1,988);
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1024';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
//Do the upload
$this->upload->do_upload("form-image")
}
請注意,我做編輯了所有的錯誤處理和這樣的。另請注意,我不使用is_uploaded_file()
函數。
感謝所有的幫助和建議。謝謝。
林不知道如果CI支持多文件上傳,我會堅持你原來的做法是否行得通,真正的線索是在名爲「幫手」。如果它對你沒有幫助,只是不要使用它。 – Philip 2012-03-23 20:22:39
在這裏回答了它:http://stackoverflow.com/questions/9276756/codeigniter-multiple-file-upload/36943949#36943949 – 2016-04-29 17:09:42