Reputation: 782
I have successfully uploaded the image files to the server using Laravel 5.0. Here is my form:
<html>
<head>
<title>Uploads</title>
</head>
<body>
{!! Form::open(array('url' => 'uploadProcessing' , 'enctype' => 'multipart/form-data')) !!}
{!! Form::label('image','Upload Image') !!}
{!! Form::file('image') !!}
{!! Form::submit('Submit') !!}
{!! Form::close() !!}
</body>
</html>
Here is my Controller:
public function uploadProcessing() {
$image = Input::file('image');
$imageName = rand(1111, 9999) . '.' . Input::file('image')->getClientOriginalExtension();
Input::file('image')->move(base_path() . '/public/uploads/', $imageName);
}
Along with that, I am saving the $imageName
as a refrence in database table.
Now I have to display that image in a view with that reference. I am trying to access it in this way:
@foreach($result as $r)
{!! HTML::image('uploads/$r->reference') !!}
@endforeach
But it is not working, any help?
Upvotes: 3
Views: 647
Reputation: 782
I got it, It was simple, I tried this:
<img src="..\uploads\{!! $r->reference !!}" />
And it worked
Upvotes: 1