Php Codeigniter 3上传未将thumb保存到目录
我正试图将缩略图保存到目录中,但它不起作用。我可以保存原始图像并将信息保存到数据库中,但由于某些原因,缩略图没有保存到我创建的thumbs目录中。该目录具有读/写访问权限。我还将注意到我正在使用Dropzone.js 这是我的部分代码:Php Codeigniter 3上传未将thumb保存到目录,php,codeigniter,Php,Codeigniter,我正试图将缩略图保存到目录中,但它不起作用。我可以保存原始图像并将信息保存到数据库中,但由于某些原因,缩略图没有保存到我创建的thumbs目录中。该目录具有读/写访问权限。我还将注意到我正在使用Dropzone.js 这是我的部分代码: if ( ! $this->upload->do_upload('file')) { //upload failed, echo back negative response to dropzone.js } else
if ( ! $this->upload->do_upload('file'))
{
//upload failed, echo back negative response to dropzone.js
}
else
{
//upload success, upload file(s)
$image_data = $this->upload->data();
$img_config['source_image'] = '/uploads/videos/'.$image_data['file_name'];
$img_config['new_image'] = '/uploads/videos/thumbs/'.$image_data['file_name'];
$img_config['create_thumb'] = TRUE;
$img_config['maintain_ratio'] = TRUE;
$img_config['width'] = 251;
$img_config['height'] = 180;
$this->load->library('image_lib', $img_config);
$this->image_lib->resize();
$file = array(
'user_id' => $this->my_auth->logged_in(),
'img_name' => $image_data['raw_name'],
'thumb_name' => $image_data['raw_name'].'_thumb',
'ext' => $image_data['file_ext'],
'upload_date' => time()
);
$this->upload_model->add_image($file);
$data['img_success'] = '<div class="alert alert-success" id="imgSuccess">Your image <strong>' . $image_data['file_name'] . '</strong> was successfully uploaded!</div>';
$this->load->view('templates/frontend/front_header', $data);
$this->load->view('templates/frontend/front_navbar');
$this->load->view('frontend/upload_images', $data);
$this->load->view('templates/frontend/front_footer', $data);
}
if(!$this->upload->do_upload('file'))
{
//上载失败,将否定响应回显到dropzone.js
}
其他的
{
//上载成功,上载文件
$image_data=$this->upload->data();
$img_config['source_image']='/uploads/videos/'.$image_data['file_name'];
$img_config['new_image']='/uploads/videos/thumbs/'.$image_data['file_name'];
$img_config['create_thumb']=TRUE;
$img_config['maintain_ratio']=TRUE;
$img_config['width']=251;
$img_config['height']=180;
$this->load->library($image\u lib',$img\u config);
$this->image_lib->resize();
$file=array(
'user\u id'=>this->my\u auth->logged\u in(),
'img_name'=>$image_data['raw_name'],
“thumb\u name”=>$image\u数据[“原始名称”]。“thumb”,
'ext'=>$image\u data['file\u ext'],
“上传日期”=>time()
);
$this->upload\u model->add\u image($file);
$data['img_success']='Your image。$image_data['file_name'].已成功上载!';
$this->load->view('templates/frontend/front_header',$data);
$this->load->view('templates/frontend/front_navbar');
$this->load->view('frontend/upload_image',$data);
$this->load->view('templates/frontend/front_footer',$data);
}
我能够成功地保存原始图像,而不是缩略图。有人看到这里有什么不对劲吗 我将此添加到我的
\u结构中
:
$this->original_path = realpath(APPPATH.'../uploads/images');
$this->thumbs_path = realpath(APPPATH.'../uploads/images/thumbs');
并更改了源图像
和新图像
配置:
$img_config['source_image'] = $image_data['full_path'];
$img_config['new_image'] = $this->thumbs_path;
这似乎已经解决了问题。如果这是答案,请单击左侧的勾号图标自行接受,使其变为绿色。谢谢