[英]Form::file notsending file to controller! Laravel5
$file = \Request::file('media')->getClientOriginalName();
For some reason, laravel (5) keeps coming back with 由于某种原因,laravel(5)不断回访
Call to a member function getClientOriginalName() on a non-object
在非对象上调用成员函数getClientOriginalName()
I have dumped $file
to see if anything has been passed, and is coming back NULL
! 我已转储
$file
来查看是否已传递任何内容,并且返回NULL
! Here is the Blade HTML Form code : 这是Blade HTML表单代码:
{!! Form::file('media' , array('enctype' => 'multipart/form-data')) !!}
Update: 更新:
If I use 如果我用
Request::get
Then I get : 然后我得到:
string(29) code-wallpaper-20-610x381.jpg
字符串(29)code-wallpaper-20-610x381.jpg
Okay, after a long and frustrating battle, I have found a solution. 好吧,经过漫长而令人沮丧的战斗,我找到了解决方案。 I dont know why this works, and I'm not sure what I changed to make it work, but I'll post what I did anyways.
我不知道为什么会这样,而且我不确定为使它起作用而进行了哪些更改,但是无论如何我都会发布。
In the 在里面
{{ Form::open }}
Add 加
'file' => 'true'
in your array. 在您的数组中。 Also replace
也更换
\Request::file()
with 与
\Input::file()
and I updated composer too! 而且我也更新了作曲家! Don't think it fixed the issue, but just posted it in case as it was one of the things I tried!
不要以为它解决了问题,但是只是发布了它,以防万一这是我尝试过的事情之一!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.