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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With