I am having trouble maintaining the correct path for uploading a file to the database.
this is my code:
public function store()
{
$input = Input::all();
try
{
$this->modelForm->validate($input);
if ( Input::hasFile('thumbnail')) {
$file = Input::file('thumbnail');
$name = time().'-'.$file->getClientOriginalName();
$file = $file->move('uploads/', $name);
$input['file'] = $file->getRealPath();
}
$model = new Model($input);
$model->save();
Redirect::back();
}
catch (FormValidationException $e)
{
return Redirect::back()->withInput()->withErrors($e->getErrors());
}
}
so ... this is what I store with this code:
/home/vagrant/code/website/public/uploads/1411468959-Bia.jpg
and this is what I need to store, I think:
public/uploads/1411468959-Bia.jpg
source
share