1
我想为图像上传做一个帮手。我可以在自定义帮助器中扩展库吗?我试图使用它,它从来没有工作。可以在codeigniter中自定义帮助程序扩展库
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
function FileUploadd($r)
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (! $this->upload->do_upload($r))
{
echo $this->upload->display_errors();
}
else
{
$Dder=$this->upload->data();
return $Dder['file_name'];
}
}
你可以发表你如何扩展它,你遇到什么错误?谢谢 – chad
函数FileUploadd($ name_file) { $ config ['upload_path'] ='./uploads/'; \t \t $ config ['allowed_types'] ='gif | jpg | png'; \t \t $ config ['max_size'] \t ='100'; \t \t $ config ['max_width'] ='1024'; \t \t $ config ['max_height'] ='768'; $ ci =&get_instance(); \t \t $ ci-> load-> library('upload',$ config); \t \t如果($ CI-> upload-> do_upload($ name_file)) \t \t { \t \t \t回声$ CI-> upload->的display_errors(); \t \t} \t \t别的 \t \t { $ Dder = $ CI-> upload->数据(); return $ Dder ['file_name']; } //在控制器中 – NewPhpProgramer101