Image.php第143行中的NotWritableException:Can';t将图像数据写入路径(C:\Users\SurajLifeean\surj\public\images/)

Image.php第143行中的NotWritableException:Can';t将图像数据写入路径(C:\Users\SurajLifeean\surj\public\images/),php,laravel-5,Php,Laravel 5,我使用的是Laravel5.2,在上传图像时遇到了一个问题。我得到一个错误,因为 NotWritableException in Image.php line 143: Can't write image data to path (C:\Users\SurajLifeean\surj\public\images/) 这个代码在我的控制器里面 $image=$request->file('featured_image'); $filename=time().'.'.$image-

我使用的是Laravel5.2,在上传图像时遇到了一个问题。我得到一个错误,因为

NotWritableException in Image.php line 143: Can't write image data to path (C:\Users\SurajLifeean\surj\public\images/)
这个代码在我的控制器里面

  $image=$request->file('featured_image');
  $filename=time().'.'.$image->getClientOriginalExtension();
  $location = public_path('images/',$filename);
  Image::make($image)->resize(800,400)->save($location);$post->image=$filename;
我一开始就有一个解决方案

use Illuminate\Support\Facades\File;
但这没用。
有谁能从您的错误消息中给我建议一个解决方案吗?您有两个问题

1)
notwriteableexception
表示您试图触摸的文件夹不可写,这意味着您需要授予该文件夹777权限

2)您在windows环境下使用UNIX目录分隔符

使用
DIRECTORY\u SEPARATOR
常量作为目录分隔符而不是固定分隔符始终是一种很好的做法

详情如下:

$location = public_path('images' . DIRECTORY_SEPARATOR, $filename);
或者简单地在您的情况下使用:

$location = public_path('images\', $filename);

我按照建议做了,但问题仍然存在。Image.php第143行中的NotWritableException:无法将图像数据写入路径(C:\Users\SurajLifeean\surj\public\images),以获得进入图像文件夹然后执行chmod 777所需的权限。对吧?@hassange图像文件夹本身777权限我刚刚也给了它权限。它成功了。