2014-05-07 75 views
-2

我想要获取使用Codeigniter中的图像裁剪库创建的新图像的文件名并将其保存在mysql数据库中。使用Codeigniter的图像裁剪库获取新图像

这是我目前种植代码:

$data['x'] = $this->input->post('x1'); 
$data['y'] = $this->input->post('y1'); 
$data['w'] = $this->input->post('width'); 
$data['h'] = $this->input->post('height'); 

$config['image_library'] = 'gd2'; 
$config['source_image'] = 'assets/images/supplier_photos/'.$this->input->post('img_file'); 
$config['create_thumb'] = TRUE; 
$config['new_image'] = './assets/images/supplier_photos/crop/'.$this->input->post('img_file'); 
$config['maintain_ratio'] = FALSE; 
$config['width'] = $data['w']; 
$config['height'] = $data['h']; 
$config['x_axis'] = $data['x']; 
$config['y_axis'] = $data['y']; 

$this->load->library('image_lib', $config); 

if(!$this->image_lib->crop()) 
{ 
    echo $this->image_lib->display_errors(); 
} 
$this->suppliers_model->update_photos(); 

现在我想创建的新图像的文件名。我怎样才能做到这一点?

+0

你试过了什么?这个问题目前太宽泛无法提供答案。 – vvanasten

+0

请检查,我更新的问题,并包括代码。谢谢! – nards

+0

它看起来像你的'$ config'数组已经有'new_image'设置为'./assets/images/supplier_photos/crop /'.$ this-> input-> post('img_file')'。该文件出现在那里?你有什么错误吗? – vvanasten

回答

0

图像的名称存储在img_file的POST值中。您可以通过$this->input->post('img_file')访问它(实际上,您的配置将它连接到路径)。您可以指定这一个像这样的变量:

$file_name = $this->input->post('img_file'); 

然后可以使用$file_name无论你想用实际文件名不带路径。