Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video uploading not working in laravel 5

Tags:

laravel-5

I am working on uploading the videos for my website. But i unable to do it. I have search many documents but i am fail to solve it. Can any one help me out to solve this problem?

I am getting an error "Call to a member function getClientOriginalName() on null"

//Form code for video upload..

{!! Form::open(array('url' => 'video' , 'files' => true)) !!}

    <div class="form-group">
    {!! Form::label('video_name', 'Video Name : ') !!}
    {!! Form::text('name',null, ['class' => 'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::label('video_path', 'Select Video : ') !!}
        {!! Form::file('path', ['class' => 'form-control'])!!}
    </div>

    <div class="form-group">
        {!! Form::submit('Upload Video')  !!}
    </div>

    {!! Form::close() !!}

//Controller Code

public function store(Request $request){

    $data = $request->all();
    if ( $request->hasFile( 'path' ) ) {
        $file = $request->file( 'path' );
        $name = $file->getClientOriginalName();
        $data[ 'path' ] = $name;
        $destination = '/public/videos';
        $request->file( 'path' )->move( base_path() . $destination, $name );
        return $name;
    }
    else {
        return '<script>alert("Fail")</script>';
    }
}

//The above code is working for images, doucments and audio but not working for videos.

Thanks in advance

like image 431
Akshay Deshmukh Avatar asked Sep 14 '25 17:09

Akshay Deshmukh


1 Answers

If your uploaded video is larger than the upload setting in your php.ini then you get this problem.

I suggest check your php.ini file and increase these directives as needed


php.ini

Example

post_max_size=200M
upload_max_filesize=200M
like image 188
code-8 Avatar answered Sep 16 '25 18:09

code-8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!