以下是codeigniter中upload
和resize
的代码。 upload
一切正常,但resize
一直给我错误:
您的服务器不支持GD功能来处理此图像类型。
function do_upload()
{
$config['upload_path'] = './gallery/gallery_big/';
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['max_size'] = '900000 * 50';
$config['max_width'] = '21024 * 50';
$config['max_height'] = '21068 * 50';
$config['remove_spaces']= TRUE;
$config['upload_url']=site_url()."gallery/gallery_big/";
$this->load->library('upload', $config);
$this->upload->initialize($config);
$field_name ="upfiles";
$upload_data = $this->upload->data();
$file_name = $upload_data['file_name'];
if(!$this->upload->do_upload($field_name))
{
$error = $this->upload->display_errors();
?>
<script type="text/javascript">
alert("<?php echo $error; ?>");
</script>
<?php
}
else
{
$success ='File Successfully Uploaded !!';
?>
<script type="text/javascript">
alert("<?php echo $success; ?>");
</script>
<?php
}
$this->resize_img();
//$this->resize_img1();
//$this->resize_img2();
}
function resize_img()
{
$config1['image_library'] = 'gd2';
$config1['source_image']='./gallery/gallery_big/';
$config1['maintain_ratio'] = TRUE;
$config1['quality'] = 100;
$config1['new_image']='./gallery/thumbnails/';
$config1['width']= 100;
$config1['height']= 100;
$this->image_lib->initialize($config1);
if(!$this->image_lib->resize())
{
$error = $this->image_lib->display_errors();
?>
<script type="text/javascript">
alert("<?php echo $error; ?>");
</script>
<?php
}
//$this->image_lib->clear();
}