我正在尝试将文件上传到 Laravel 5.4 中的 C:\Users\sandeep\maxo\storage\app\public 文件夹。我正在使用下面的代码
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="{{ URL::to('importExcelFile') }}" class="form-horizontal" method="post" enctype="multipart/form-data">
<input type="file" name="import_file" />
{{ csrf_field() }}
<br/>
<button >Import CSV or Excel File</button>
</form>
</body>
</html>
$path = $request->file('import_file')->store('public');
是laravel代码。
但是我遇到这样的错误
fopen(C:\Users\sandeep\maxo\storage\app\public/K4oIHMXveyx2VChmAXAcNkTmoIXKACvqoIbbHCeB.): failed to open stream: Permission denied
这是我错误的图片 Click here
但是当我上传图片时它工作正常
最佳答案
正如各处所述,您最好不要授予 777
权限,这是一种安全风险。而只是使用
sudo chown -R www-data:www-data storage
如果你使用的是apache,它会给apache的用户权限
关于php - 无法打开流 : Permission denied in Laravel 5. 4 即使 Al 文件权限也被授予使用 Laravel 5.4 中的存储功能的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44918594/