我正在一个需要文件上传的项目。我已经实现了Dropzone.js和Laravel框架。我确定我已经正确设置了所有内容,但是当我将文件拖放到dropzone并完成上传后,会出现此错误
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function getRealPath() on a non-object","file":"C:\\wamp\\www\\local\\app\\controllers\\AssetsController.php","line":119}}
这是我的路线
Route::post('create/album','AssetsController@album');
这是我的控制器
$path = "assets";
$fileee = Input::file('file');
Image::make($fileee->getRealPath())->resize(500, null, true)->save($path);
当我与laravel检查是否有文件时,它返回NULL,但是当我var_dump()Input :: file()时,我得到了与文件相关的数据数组,我已经在网上搜索了,似乎找不到任何东西。
提前致谢!
我终于想出了解决的方法,这就是解决的方法,这是我更改后的控制器
$fileee = Input::file('file');
Image::make($fileee[0]->getRealPath())->resize(540, null, true)->save('assets/example.png');
如果有人在问那些图像处理方法从何而来,那就是使用http://intervention.olivervogel.net/image/getting_started/laravel的类iam。
希望这对未来的人有所帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句