Php 上载配置文件Pic laravel时出错
我目前正在使用laravel,我的错误是 图像源不可读 我使用了Php 上载配置文件Pic laravel时出错,php,laravel,image-uploading,Php,Laravel,Image Uploading,我目前正在使用laravel,我的错误是 图像源不可读 我使用了$php composer.phar require interference/image。它已成功安装 我复制了这些用于laravel集成 $providers: Intervention\Image\ImageServiceProvider::class, $别名: 'Image' => Intervention\Image\Facades\Image::class, 我的错误: NotReadableExce
$php composer.phar require interference/image
。它已成功安装
我复制了这些用于laravel集成
$providers:
Intervention\Image\ImageServiceProvider::class,
$别名:
'Image' => Intervention\Image\Facades\Image::class,
我的错误:
NotReadableException in AbstractDecoder.php line 302:
Image source not readable
我的UserController文件:
if($request->hasFile('avatar')){
$avatar = $request->file('avatar');
$filename = time() . '.' . $avatar->getClientOriginalExtension();
Image::make('$avatar')->resize(300, 300)->save(
public_path('/uploads/avatars/' . $filename));
}
return redirect()->route('dashboard');
}
我的路线文件:
Route::post('/dashboard',[
'uses'=>'UserController@update_avatar',
]);
尝试将make()
零件更改为:
Image::make($avatar->getRealPath())->resize(....
当我将文件路径更改为null时,Image::make($avatar->getRealPath())->resize(300300)->save(public_path('.$filename)),无法将图像数据写入路径(C:\wamp64\www\Final Group\public\/uploads/avatars/1471074992.png);页面刚刚刷新,新图片未上载。相同的默认图片再次出现在将
公共路径('/uploads/avatars/'.$filename)
更改为公共路径('uploads'.DIRECTORY\u SEPARATOR.$avatars'.DIRECTORY\u SEPARATOR.$filename)
。另外,由于您使用Windows,请尝试递归删除上传
文件夹中的只读
标志。相同错误:Image.php第143行中的NotWritableException:无法将图像数据写入路径(C:\wamp64\www\Final Group\public\uploads\avatars\1471076825.png)我猜您没有将代码更改为我的代码,但是合并了它们,现在你得到了:\uploads/uploads/avatars/avatars/uploads/avatars/
。我看不到您当前的代码,所以我无法在这里提供帮助,但它确实很容易修复。