我正在使用此功能上传多张图片。 它在新的codeigniter设置中工作正常。但是当我在现有网站(codeigniter)中使用它时,它无法工作,也没有向我显示任何警告或错误。我没有得到我所缺少的东西。在调用函数$ this-> upload-> do_multi_upload(“uploadfile”)后,它没有显示任何内容。
public function do_upload(){
// Detect form submission.
if($this->input->post('submit')){
$path = './uni_images/';
$this->load->library('upload');
$this->upload->initialize(array(
"upload_path" => $path,
"allowed_types" => "gif|jpg|png",
"max_size" => '10000',
"max_width" => '1024000',
"max_height" => '7680000'
));
if($this->upload->do_multi_upload("uploadfile")){
echo "12";
$data['upload_data'] = $this->upload->get_multi_upload_data();
echo '<p class = "bg-success">' . count($data['upload_data']) . 'File(s) successfully uploaded.</p>';
} else {
echo "13";
// Output the errors
$errors = array('error' => $this->upload->display_errors('<p class = "bg-danger">', '</p>'));
foreach($errors as $k => $error){
echo $error;
}
}
} else {
echo '<p class = "bg-danger">An error occured, please try again later.</p>';
}
exit();
}
这是我的html代码,用于调用上面的函数
<?php echo form_open_multipart('welcome_image/do_upload', array('class' => 'upload-image-form'));?>
<input type="file" multiple = "multiple" accept = "image/*" class = "form-control" name="uploadfile[]" size="20" /><br />
<input type="submit" name = "submit" value="Upload" class = "btn btn-primary" />
</form>
答案 0 :(得分:0)
尝试将ENVIRONMENT设置为development
并在index.php中的根目录下添加ini_set('display_errors', 1);
以显示错误。此外,请确保您的./uni_images/
路径可写。
据我所知,do_multi_upload
不是codeigniter上传库中的内置方法。 Here是通过扩展本机codeigniter上传库的第三方库。
希望它对你有用。