lundi 26 janvier 2015

Upload video with Laravel


Vote count:

0




I have a problem with my upload in laravel. My view :



{{ Form::open(array('url'=>'administration/video/create','method' => 'post','files'=>true)) }}
<p>
{{ Form::label('Titlu:') }}
{{ Form::text('title',null,array('class'=>'form-control')) }}
</p>
<p>
{{ Form::label('Description:') }}
{{ Form::text('description',null,array('class'=>'form-control')) }}
</p>
<p>
{{ Form::label('image','Imagine:') }}
{{ Form::file('image','',array('id'=>'','class'=>'')) }}
</p>
<p>
{{ Form::label('video','Video:') }}
{{ Form::file('video','',array('id'=>'','class'=>'')) }}
</p>
{{ Form::submit('Add',array('class'=>'btn btn-primary')) }}
{{ Form::reset('Reset',array('class'=>'btn btn-success')) }}
{{ Form::close() }}


My controller:



public function postCreate(){
$video = new \Video();
$video->title = Input::get('title');
$video->description = Input::get('description');
$video->video_image = '';
$video->video_name = '';
if(Input::hasFile('image')) {
$sImagePermalink = \Url_Lib::makePermalink($video->title);
$image = Input::file('image');
$filename = $sImagePermalink . "." . $image->getClientOriginalExtension();
$path = public_path('content/video/' . $filename);
Image::make($image->getRealPath())->resize(468, 249)->save($path);
$video->video_image = 'content/video/' . $filename;

$videoDocument = Input::file('video');
$videofile = $sImagePermalink . "." . $videoDocument->getClientOriginalExtension();
$pathVideo = public_path('content/video/' . $videofile);
Input::file('video')->move('content/video/', $pathVideo);
$video->video_name = 'content/video/' . $videofile;
}

$video->save();
return Redirect::to('/administration/video/add/')
->with('message_succes','Video added');
}


I get an error : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null I don't understand why? Please help me.



asked 37 secs ago







Upload video with Laravel

Aucun commentaire:

Enregistrer un commentaire