使用codeigniter将生成的条形码图像保存在数据库和文件夹中 [英] Save generated bar code image in database and in folder using codeigniter

查看:190
本文介绍了使用codeigniter将生成的条形码图像保存在数据库和文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用图库来生成条形码。生成条形码,但问题是如何保存生成的图像?

I have used library to generate barcode. Bar code is generated but problem is that how can i save that generated image?

这里我给我的代码我使用了:

Here i am giving my code i have used:

在控制器中:

In controller:

function add($bar_code)
{
   $postData['bar_code'] = $this->set_barcode($postData['bar_code']);
}

function set_barcode($code)
{
    $this->load->library('zend');
    $this->zend->load('Zend/Barcode');
    $bar_code = Zend_Barcode::render('code128', 'image', array('text'=>$code), array('imageType' => 'jpg'))->draw();
    return $bar_code;
}

如何保存生成的条形码的图像?

How can i save the image of generated bar code?

尽可能帮助儿子。

谢谢!

推荐答案

我得到解决方案

function set_barcode($code)
{
   $this->load->library('zend');
   $this->zend->load('Zend/Barcode');
   $file = Zend_Barcode::draw('code128', 'image', array('text' => $code), array());
   $code = time().$code;
   $store_image = imagepng($file,"../barcode/{$code}.png");
   return $code.'.png';
}

使用imgepng函数存储图像。

它会将条形码图像存储在条码文件夹中。

store the image using imgepng function.
it will store the bar code image in barcode folder.

这篇关于使用codeigniter将生成的条形码图像保存在数据库和文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆