我在显示我在数据库中上传的图像时遇到了麻烦。我认为是因为我没有正确保存图像?
在我的控制器中:
if ( Input::hasFile('thumbnail') ) {
$file = Input::file('thumbnail'); // Get the image input
$destinationPath = 'uploads/images/thumbnails'; // The destination were you store the image.
$filename = time() . '_' . $file->getClientOriginalName() ; // Original file name that the end user used for it.
$file = $file->move($destinationPath, $filename); // Now we move the file to its new home.
$input['thumbnail'] = $file->getRealPath();
}
$model = Model::create($input);
我试着展示这两件事,但这都不起作用:
<img src='{{ asset($model->thumbnail) }}'>
<!-- {{ HTML::image( $model->thumbnail, 'foto') }} -->
这是数据库上的路径: /home/vagrant/code/myApp/public/uploads/images/thumbnails/1405976987_C360_2014-05-31-22-09-28-012.jpg