Laravel 5.4 fopen():文件名不能为空 [英] Laravel 5.4 fopen(): Filename cannot be empty

查看:275
本文介绍了Laravel 5.4 fopen():文件名不能为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在laravel 5.4中上传图片 这是代码:

I want to upload image in laravel 5.4 Here's the code:

if ($request->hasFile('image') && $request->image->isValid()) {
        $image = $request->image;

        $image_name = bcrypt($image->getClientOriginalName());

        Storage::disk('public')->putFileAs('images', $image, $image_name . '.' . $image->getClientOriginalExtension());

        $article->image($image_name);
    }

在FilesystemAdapter.php中(第146行)

in FilesystemAdapter.php (line 146)

我检查了FileSystemAdapter.php,发现问题出在这一行:

I checked the FileSystemAdapter.php and saw that the problem is in this line:

$stream = fopen($file->getRealPath(), 'r+');

当我var dump $ file变量时,它返回正确的信息,但是当我var_dump($file->getRealPath();时它说bool(false)并且我无法上传图像

When I var dump the $file variable it returns the correct info, but when I var_dump($file->getRealPath(); it says bool(false) and I can't upload the image

推荐答案

我们在Windows®Server的Internet信息服务(IIS)中遇到了此问题.唯一需要做的就是-允许C:\ Windows \ temp,因为它在php7的php.ini中被设置为upload_tmp_dir.

We had this problem with Internet Information Services (IIS) for Windows® Server. And only thing needed was - permission for C:\Windows\temp because it is set as upload_tmp_dir in php.ini for php7.

这篇关于Laravel 5.4 fopen():文件名不能为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆