【发布时间】:2016-09-29 11:52:51
【问题描述】:
我在 laravel 项目中遇到了一些 GD 问题。我的 phpinfo 显示 GD 已启用,但出现“未定义函数 Intervention\Image\Gd\imagecreatefrompng()”错误。
当我尝试执行此操作时,我遇到了这些问题:
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.'/flyer2.png', $unencodedData);
return view('backend.flyers.index')->withImgoutput($imgoutput);
//->withStoragepath($storagepath);
}
【问题讨论】:
-
在执行的什么时候收到错误信息?
-
我正在将 laravel 项目中的图像保存在文件夹中。当我尝试在浏览器中查看图像时,我收到错误消息。 Photoshop 也告诉我文件已损坏。
-
如果您有任何与此问题相关的代码或设置,您也应该发布它们。我帮不了你,因为我对 laravel 一无所知,但是你写的问题越好,你就越有可能得到答案。
-
public function update(Request $request, $id) { //显示图片 echo ''; //从数据中获取base-64字符串 $filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1); //解码字符串 $unencodedData=base64_decode($filteredData); $storagepath = storage_path('app/images/users/' . Auth::user()->id); $imgoutput = File::put($storagepath.'/flyer.jpg', $unencodedData);返回视图('backend.flyers.index')->withImgoutput($imgoutput); //->withStoragepath($storagepath); }
-
这是我用来保存图像的功能。通过尝试在我的浏览器中查看它,我收到了错误消息