我正在处理一个需要上传文件的项目。我已经实现了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()the Input::file()时,我得到了一组与文件相关的数据,我在网上搜索了一下,似乎什么都找不到。
提前感谢!
我终于想好了如何修复它,这就是修复它的原因,这是我更改的控制器
$fileee = Input::file('file');
Image::make($fileee[0]->getRealPath())->resize(540, null, true)->save('assets/example.png');
如果有人问这些图像处理方法是从哪里来的,这就是iam使用的类http://intervention.olivervogel.net/image/getting_started/laravel
希望这对未来的有帮助
我也搜索了一个答案,但得到了一个解决方案。
Dropzone有这样的设置:
uploadMultiple: true
如果将其设置为true
,它将形成一个数组,这就是为什么需要执行$fileee[0]
。如果只允许发送一个图像,请将其更改为false
,您将获得一个对象。