验证请求视频文件(Laravel)

时间:2018-06-04 03:10:42

标签: php laravel

问题:我以正确的格式上传视频时遇到问题。 错误说。 内容资产无法上传。

我上传的文件名是 的 history_legend.mp4

视频格式正确。

我尝试自定义我的php.ini max_upload_size到500M

但仍然无法上传错误

在控制器中:

public function content_inserting_home(Request $request)
{

    $content_bothimagevideo = $request->input('content_assets');
    $file_upload = $request->file('content_assets');

     $validatedData = $request->validate([
    'content_assets' => 'required|mimes:mp4,x-flv,x-mpegURL,MP2T,3gpp,quicktime,x-msvideo,x-ms-wmv',

    ]);


}

在Blade中

<form action="/previllage/content_inserting_home" method="post" enctype="multipart/form-data"> 
         {{csrf_field()}}
        <div class="collection">
            <a href="#!" class="collection-item active " style="border-left:5px solid black;">Home</a>
            <a href="#!" class="collection-item" style="cursor: default;">
                <div class="row">

                    <div class="input-field col s12 m4 l4">
                        <select name="content_page">
                          <option value="" disabled selected>Select the page where you publish</option>
                          <option value="Home">Home</option>
                        </select>
                        <label>Choose the page</label>
                    </div>
                    <div class="input-field col s12 m4 l4">
                        <select name="content_section">
                          <option value="" disabled selected>Select section where you put it in</option>
                          <option value="Sec1">Section 1</option>
                          <option value="Sec2">Section 2</option>
                          <option value="Sec3">Section 3</option>
                          <option value="Sec4">Section 4</option>
                          <option value="Sec5">Section 5</option>
                        </select>
                        <label>Choose the page</label>
                    </div>
                    <div class="input-field col s12 m4 l4">

                      <input placeholder="Title" name="content_header" id="title" type="text" class="validate">
                      <label for="first_name">Header</label>

                    </div>


                    <br>

                </div>      
            </a>
                <div class="row">
                    <a href="#!" class="collection-item" style="cursor: default;">
                        **<div class="file-field input-field col s12 m10 l10">
                          <div class="btn">
                            <span>File</span>
                            <input type="file"  name="content_assets"  >
                          </div>
                          <div class="file-path-wrapper">
                            <input class="file-path validate" name="content_assets" placeholder="Upload Here the video & Image" type="text">
                          </div>
                           @if ($errors->has('content_assets'))
                          <span class="help-block">
                                  <strong style="color:red;">{{ $errors->first('content_assets') }}</strong>
                              </span>
                          @endif**

                        </div>
                        <img id="image-viewer" src="http://placehold.it/150" alt="your image" />
                    </a>
                </div>
                         {{-- <img id="image-viewer" src="http://placehold.it/250" alt="your image" /> --}}



            <a href="#!" class="collection-item" style="cursor: default;">
                <div class="input-field col s12 m6 l6">
                   <textarea  name="content_article" id="test"  maxlength="6000" required style="resize:none; position: relative; top:5px; border-top:0px; border-left:0px; border-right:0px;"></textarea>
                   <label>Article</label>
                </div>

            </a>

        </div>
         <button class="btn waves-effect btn-large waves-light red darken-4 right" type="submit">Publish & Save
            <i class="material-icons right">send</i>
         </button>
    </form>

0 个答案:

没有答案