【发布时间】:2018-02-14 01:13:51
【问题描述】:
我正在尝试为图像上传做一个助手。我可以在自定义助手中扩展库吗?我曾尝试使用它,但它始终无法使用。
<?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'];
}
}
【问题讨论】:
-
你能发布你如何扩展它,你遇到什么错误?谢谢
-
函数 FileUploadd($name_file) { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $ci =& get_instance(); $ci->load->library('upload', $config); if ( $ci->upload->do_upload($name_file)) { echo $ci->upload->display_errors(); } else { $Dder=$ci->upload->data();返回 $Dder['file_name']; } //在控制器中
标签: codeigniter helper extend