2017-02-13 65 views
0

我想上傳圖片,然後調整其大小 然後出現錯誤Image_lib路徑名稱錯誤,服務器不支持GD功能

「到圖像的路徑不是correct.Your服務器不支持GD功能需要處理這種類型的圖像。「 但在$ config ['source_image'] ='./production/images/'.$id_akun.'jpg'; 是我從'upload_path'=>「./production/images/」, 的路徑,爲什麼我的路徑不正確? 這是我在控制器

   $id_akun=29; 
        $config = array(
        'upload_path' => "./production/images/", 
        'allowed_types' => "jpg", 
        'file_name' => $id_akun, 
        'overwrite' => true, 
        'max_size' => "2048", 
        'max_height' => "768", 
        'max_width' => "1024" 
        ); 
        $this->upload->initialize($config); 

        if($this->upload->do_upload('userfile')) 
         { 
        $data = array(
         'id' => $id_akun, 
         'foto' => $this->upload->file_name 
         ); 
         $this->User_model->upload($id_akun,$data); 
         $config['image_library'] = 'gd2'; 
         $config['source_image'] = './production/images/'.$id_akun.'jpg'; 
         $config['create_thumb'] = TRUE; 
         $config['maintain_ratio'] = TRUE; 
         $config['width']   = 220; 
         $config['height']  = 220; 
         $config['create_thumb'] = TRUE; 
         $this->image_lib->clear(); 
         $this->image_lib->initialize($config); 
         $this->image_lib->resize(); 

         $er=$this->image_lib->display_errors(); 
         echo json_encode($er); 
         exit(); 
         } 

回答

0

GD功能是一個PHP擴展,它處理的圖像處理。您正在加載的庫需要它的工作。 GD:http://php.net/manual/en/book.image.php

如果您沒有訪問服務器直接你有點運氣的,除非你能得到的託管服務提供商爲您提供了擴展。

如果你有服務器及其上的Linux,你可以使用軟件包管理器安裝(作爲root用戶,或使用sudo的)

的CentOS/RHEL是: yum install php-gd

Ubuntu的: apt-get install php-gd

安裝這些擴展後,您將需要重新啓動你的web服務器加載更新的php.ini文件。

除此之外,使用./開始您的路徑可能沒有幫助,請在開始時刪除.。我還建議確保文件夾路徑從web-root退出,並且在文件夾上設置了正確的權限(如果服務器是linux並且web服務器擁有目錄和文件的所有權),確保您擁有正確的chmod集合

+0

我使用本地計算機的Windows服務器,幷包含擴展名php_gd2,我試圖刪除。在路徑,但仍然是相同的錯誤 – faza

+0

錯誤是沒有找到GD,所以它不能做你要求它做的圖像處理 –

+0

我在phpinfo GD支持啓用支持 – faza

相關問題