【发布时间】:2018-02-12 18:17:42
【问题描述】:
我有上传base64图片的功能:
public function upload(UploadImageRequest $request) {
$data = (\Request::input('image'));
$decode = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));
$info = @getimagesizefromstring($decode);
$extn = image_type_to_extension($info[2]);
if ($extn ==".png"){
$fullName = md5(time().uniqid()).$extn;
Storage::disk('public')->put('images/',$fullName, $decode);
$image = Image::make();
$image->url = Storage::url($fullName);
$image->saveOrFail();
return Response::json($image, ResponseHttp::HTTP_CREATED);
}
else {dd(1);}
}
我尝试将我的图像保存到 public/image/ 目录,但失败了。
错误:
(1/1) ErrorException
file_put_contents(/home/artem/PhpstormProjects/thefeedfeed-api/storage/app/public/images): failed to open stream: Is a directory
【问题讨论】:
-
我认为你的目录有权限问题!!你能指出你的确切错误吗
-
更新帖子并添加错误
-
更新帖子并添加错误 - @katedega 但这是你的问题吗? :O
-
@Script47 - 我在帖子中有错误。我做错了什么?或者如何将文件保存到我需要的目录?
-
@katedega 请检查这个 =>> stackoverflow.com/questions/14560658/…
标签: php laravel laravel-5 php-7