簡體   English   中英

Laravel 調用未定義的函數 Intervention\\Image\\Gd\\imagecreatefrompng()

[英]Laravel Call to undefined function Intervention\Image\Gd\imagecreatefrompng()

嗨,我在laravel項目中使用 glide ( http://glide.thephpleague.com/ ) 進行圖像處理。 我在存儲圖像時遇到問題。 “調用未定義的函數Intervention\\Image\\Gd\\imagecreatefrompng()

奇怪的是,我可以在我的 mac 上用“預覽”打開圖像。 但不是在瀏覽器中。 Photoshop 還告訴我這個文件有問題,它已損壞。

這是我將圖像保存在私人文件夾中的方式:

public function update(Request $request, $id)
{

  //Show the image
  echo '<img src="'.$_POST['img_val'].'" />';

  //Get the base-64 string from data
  $filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1);

  //Decode the string
  $unencodedData=base64_decode($filteredData);

  //Save the image
  $storagepath = storage_path('app/images/users/' . Auth::user()->id);
  $imgoutput = File::put($storagepath.'/flyer.jpg', $unencodedData);

  return view('backend.flyers.index')->withImgoutput($imgoutput);
                                     //->withStoragepath($storagepath);

}

似乎 File::put( XXX.jpg ) JPG導致了問題。 我怎樣才能解決這個問題?

這是因為缺少GD Library 嘗試這個:

您必須啟用庫 GD2。

找到你的(正確的) php.ini文件

找到這一行: ;extension=php_gd2.dll ,去掉前面的分號。

該行應如下所示:

extension=php_gd2.dll

然后重新啟動apache,你應該很高興。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM