Laravel file upload: access file from server
I have successfully uploaded 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);
}
Also, I am saving $imageName
as a refrence in the database table. Now I have to display this image in the view with this link. I am trying to access it this way:
@foreach($result as $r)
{!! HTML::image('uploads/$r->reference') !!}
@endforeach
But it doesn't work, no help?
+3
source to share