Laravel 5.4文件是真的但仍然在null错误上给出了getClientOriginalExtension()

时间:2017-07-26 08:31:25

标签: forms laravel-5 laravel-5.4

正如我在标题上所说,转过来的文件'为true但仍然在null错误上给出函数getClientOriginalExtension()。

形式;

{{Form::open(['route'=>'save.news','files'=> true])}}
{{Form::news_input('head','enter head')}}
<div class="form-group">
 <div class="col-md-10">
  <label>create article</label>
   <textarea id="article-ckeditor" name="content" placeholder="Write your message.." class="form-control ckeditor"></textarea>
 </div>
</div>
{{Form::news_input('keywords','enter tags)}}    
{{ Form::upload_form('post_featured') }}
 <div class="form-group">
  <div class="col-xs-10">
   <label>
Publish
   </label>
<input type="submit" class="btn-success">
</div>
</div>
{{Form::close()}}

自定义文件格式;

<div class="form-group">

    <div class="col-xs-10">

        <div class="fileupload fileupload-new" data-provides="fileupload">
            <label>
                Featured İmage;
            </label> <br>
            <span class="btn btn-file btn-default">
                                    <span class="fileupload-new">Select file</span>
                                    <span class="fileupload-exists">Change</span>
                {{ Form::file()}}                                    

            <span class="fileupload-preview"></span>
            <a href="#" class="close fileupload-exists" data-dismiss="fileupload" style="float: none">×</a>
        </div>
    </div>
</div>

和我的控制器

        $request->all();
        $head = $request->input('head');
        $content = $request->input('content');
        $keywords = $request->input('keywords');
        $featured=$request->input('post_featured');

        $photoName = $featured . '.' . rand(11111, 99999) . '.' . $request->post_featured->getClientOriginalExtension();
        $request->post_featured->move(public_path('uploads'), $photoName);
        News::create(array('head' => $head, 'content' => $content, 'keywords' => $keywords,'post_featured'=>$photoName));

我在哪里弄错了? (我知道,我是初学者......)

0 个答案:

没有答案