【问题标题】:CodeIgniter WatermarkingCodeIgniter 水印
【发布时间】:2014-07-12 14:11:10
【问题描述】:

您好,我的代码有问题

    $obj = new stdClass();
    $obj->cat_id = !empty($_POST['cat_id']) ? $_POST['cat_id'] : '';
    $obj->num_chapter = !empty($_POST['num_chapter']) ? $_POST['num_chapter'] : '';
    $obj->tags = !empty($_POST['tags']) ? $_POST['tags'] : '';
    $obj->date = date("Y-m-d H:i:s");


    $config['upload_path'] = $this->model_mangachapt->Add($obj);
    $config['encrypt_name'] = false;
    $config['allowed_types'] = "png|jpg|jpeg";
    $config['max_size'] = "1000000";

    $this->upload->initialize($config);

    $img_config['source_image'] = $this->upload->do_multi_upload('userfile');
    $img_config['image_library'] = 'gd2';
    $img_config['wm_type'] = 'overlay';
    $img_config['wm_overlay_path'] = './images/logo.gif';
    $img_config['wm_vrt_alignment'] = 'middle';
    $img_config['wm_hor_alignment'] = 'center';

    $this->image_lib->initialize($img_config);
    print $this->image_lib->watermark();

我想要更新图像后将徽标从网络上删除。 但是如果我上传我会给我错误

错误是:

A PHP Error was encountered
Severity: Warning
Message: imagecolorat() expects parameter 1 to be resource, boolean given
Filename: libraries/Image_lib.php
Line Number: 953

【问题讨论】:

  • 如果您使用 CI,为什么要直接访问 $_POST?此外,错误消息非常简单。对 imagecolorat() 的调用在哪里进行?
  • 是一个测试。我检查了上传图片的水印,但不工作。但如果我做新的功能是工作
  • 现在在我稍微更改代码后出现此错误:严重性:警告消息:imagecopy() 期望参数 1 是资源,布尔值给定文件名:libraries/Image_lib.php 行号:948

标签: php css codeigniter error-handling imagelibrary


【解决方案1】:

我觉得问题出在这里

$img_config['source_image'] = $this->upload->do_multi_upload('userfile');

此函数执行文件的上传,并返回一个布尔值以检查上传是否成功。我没有给出图片的url。

我猜你正在使用这个库进行多次上传:https://github.com/stvnthomas/CodeIgniter-Multi-Upload

您应该改用函数 get_multi_upload_data() 来查找要使用的正确文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-15
    • 2020-03-10
    • 1970-01-01
    • 2022-01-16
    相关资源
    最近更新 更多