我正在尝试在上传的图像上添加水印,但是即使-> watermark()函数返回1
,也不会添加水印。
我首先将图像添加到临时文件夹中,以防用户取消该过程,这就是我要对图像加水印的地方。
到目前为止,这是我的代码:
public function upload_temp_image($file_name)
{
$watermarkSrc = $this->upload_model->get_watermark_src();
if (isset($_FILES[$file_name])) {
if (empty($_FILES[$file_name]['name'])) {
return null;
}
}
$config['upload_path'] = './uploads/temp/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['file_name'] = 'img_temp_' . generate_unique_id();
$this->load->library('upload', $config);
if ($this->upload->do_upload($file_name)) {
$data = array('upload_data' => $this->upload->data());
if (isset($data['upload_data']['full_path'])) {
//watermark the image
print_r($data['upload_data']['full_path']);
$imgConfig = array();
$imgConfig['image_library'] = 'GD2';
$imgConfig['source_image'] = $data['upload_data']['full_path'];
$imgConfig['wm_type'] = 'overlay';
$imgConfig['wm_overlay_path'] = 'https://hackteam.co/'.$watermarkSrc;
$this->load->library('image_lib', $imgConfig);
$this->image_lib->initialize($imgConfig);
$this->image_lib->watermark();
return $data['upload_data']['full_path'];
}
return null;
} else {
return null;
}
}
我的路径错误吗?如何调试此功能?