Laravel 5.4 fopen()函数:文件名不能为空
问题描述:
我要上传图片中laravel 5.4 下面的代码:Laravel 5.4 fopen()函数:文件名不能为空
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)
我检查了FileSystemAdapter.php,发现问题出在这一行:
$stream = fopen($file->getRealPath(), 'r+');
当我var转储$文件变量它会返回正确的信息,但当我var_dump($file->getRealPath();
它说bool(false)
,我不能上传图像
答
我们有这个问题与Windows Server的Internet信息服务(IIS)。唯一需要的是 - 对C:\ Windows \ temp的权限,因为它在php.ini中设置为upload_tmp_dir。
试着改变'$ image = $ request-> image;'到'$ image = $ request-> file('image');' – Laerte
@Laerte结果是一样的 – TheAngelM97
它对我很好。 'image'方法做了什么? – louisfischer