i have some problems. I want to load an image that it is on storage folder. I want to load by a route call. This is my code. function :
public function getImage($filename) {
$path = storage_path() . '/media/thumbnails/' . $filename;
if(!File::exists($path)) abort(404);
$file = File::get($path);
$type = File::mimeType($path);
$response = Response::make($file,200);
$response->header("Content-Type", $type);
return $response;
}
this is my route:
Route::get('/media/getImage/{$filename}', ['as' => 'getImage',
'uses' => 'MediaController@getImage']);
and this is my html :
<img style="width: 100%; display: block;" src="
"
this is my index function that load media gallery view :
public function index() {
$directory = realpath(storage_path("media/thumbnails"));
$files = File::allFiles($directory);
foreach ($files as $file ) {
$img[] = str_replace('/var/www/html/pgmailplatform/storage/media/thumbnails/', '', $file);
}
return view('media/media', ['user' => Auth::user(), 'images' => $img ]);
}
How i can load the image in ?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tvU87y
via IFTTT
Aucun commentaire:
Enregistrer un commentaire