PHP fopen():文件名不能为空,原因是getRealPath返回false [英] PHP fopen(): Filename cannot be empty cause by getRealPath return false

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

问题描述

我正在使用Laragon在Windows 10上本地开发Laravel项目

I'm developing Laravel project on Windows 10 locally using Laragon

PHP版本:7.1.8 64bit NTS

PHP version: 7.1.8 64bit NTS

相关php.ini

post_max_size = 8M

post_max_size = 8M

file_uploads =开启

file_uploads = On

源代码:

// if no image uploaded
if (!$request->hasFile('profile_picture')) 
throw new \Exception("No image found");

// get uploaded image
$image = $request->file('profile_picture');

// store to storage/app/users/
Storage::putFileAs('users', $image ,auth()->id());

我认为这是服务器配置问题,可能是php.ini上的问题,

In my opinion, this is server configuration issue, probably problem on php.ini,

但是我不熟悉服务器配置,并且没有太多与该问题相关的在线主题.

but I'm not familiar with server configuration, and there is not so many topics online related with this issue.

我知道问题的原因,但我不知道如何解决.

I know the problem cause, but I don't know how to solve it.

推荐答案

您确定运行Web服务器进程用户的用户具有对Windows TEMP目录的RW(读/写)访问权限吗?如果没有,您肯定会失败!

Are you sure that the user that runs your Web Server Process User has RW (Read/Write) access to Windows TEMP Directory? If no, you will definitely fail!

对此的一种可能的解决方法是将PHP TEMP Dir设置为可读/可写的位置.

A possible fix for this is to set the PHP TEMP Dir to a readable/writeable location.

在您的php.ini上设置此指令.

upload_tmp_dir ='PATH'

确保"PATH"存在,并且您的Web服务器进程用户具有对其的读/写访问权限.

Make sure that the 'PATH' exists and your Web Server Process User has read/write access to it.

Web服务器进程用户是Web服务器用来运行服务的帐户.您可以在任务管理器中检查此内容.

Web Server Process User is the account that is used by your web server to run the service. You can check this on the Task Manager.

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

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