Php 使用codeigniter上传并调整图像大小
这是我在codeigniter中上传和调整大小的代码。Php 使用codeigniter上传并调整图像大小,php,codeigniter,Php,Codeigniter,这是我在codeigniter中上传和调整大小的代码。上传一切正常,但调整大小不断给我错误: 您的服务器不支持GD函数来处理此映像类型 函数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';
上传一切正常
,但调整大小
不断给我错误:
您的服务器不支持GD函数来处理此映像类型
函数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'];
如果(!$this->upload->do\u upload($field\u name))
{
$error=$this->upload->display_errors();
?>
警报(“”);
警报(“”);
警报(“”);
仅供参考,您的php
标记是反向的。您不能在类的方法中以这种方式使用JS代码。另外,如果您使用line$this->upload->initialize($config)
那么在加载库时就不需要第二个参数了。福戈特说,我不确定你到目前为止是否在软件上搜索过,以及你的问题和找到的问题有什么不同,但可能会有所帮助。我只需要简单的谷歌搜索“你的服务器不支持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();
}