本文介绍了空白图像-图像干预Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用Image Intervention类保存图像时,文件会保存,但显示为空白.我给它发送了base64字符串.
When I save a image using the Image Intervention class my file saves but shows as blank. I send it a base64 string.
当前是我的代码.
$file = Input::file($_POST['data']);
$img = Image::make($file);
$fileName = "profiles/".md5(time()).'.png';
$path = public_path($fileName);
if($img->save($path)){
$user = User::find(Auth::user()->id);
$user->location->start_image = $fileName;
$user->push();
}
print_r($ _ POST ['data'])-> http://pastebin.com /BGbUeZhr
谢谢
- 我尝试过$ file = Input :: file(base64_decode($ _ POST ['data']));这不起作用
推荐答案
也许我丢失了一些东西,但是当图像为base64时却使用Input::file
对我来说似乎是错误的. Input::file
用于检索以html格式上传的文件.
Maybe I'm missing something but using Input::file
when you have the image as base64 looks just wrong to me. Input::file
is for retrieving a file that has been upload with an html form.
假设$_POST['data']
是base64编码的图像,请尝试以下操作:
Assuming $_POST['data']
is a base64 encoded image, try this:
$img = Image::make($_POST['data']);
甚至更好:
$img = Image::make(Input::get('data'));
这篇关于空白图像-图像干预Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!