0
我對上傳圖像機能的研究用base64:file_put_contents(...):未能打開流:是一個目錄
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);}
}
我嘗試我的圖像保存到公共/圖像/目錄,但失敗了。
錯誤:
(1/1) ErrorException
file_put_contents(/home/artem/PhpstormProjects/thefeedfeed-api/storage/app/public/images): failed to open stream: Is a directory
我認爲您的目錄中存在權限問題!你能否請你顯示你的確切的錯誤 –
更新帖子,並添加錯誤 – katedega
*更新帖子和添加錯誤* - @ katedega但它是你的問題? :O – Script47