Skip to content

Instantly share code, notes, and snippets.

@ferdiunal
Last active June 22, 2016 09:12
Show Gist options
  • Save ferdiunal/c922704881fa213b914292c36dab5196 to your computer and use it in GitHub Desktop.
Save ferdiunal/c922704881fa213b914292c36dab5196 to your computer and use it in GitHub Desktop.
Laravel'de farklı dizindeki dosyaları kendi oluşturduğumuz url'ler ile nasıl göstereceğimizi aşağıda belirttim. $path değişkeni sizin dosyanızın yolunu belirler.
<?php
/***
* Laravel'de farklı dizindeki dosyaları kendi oluşturduğumuz url'ler ile
* nasıl göstereceğimizi aşağıda belirttim.
* $path değişkeni sizin dosyanızın yolunu belirler.
*/
Route::get('/img/{user_id}/{filename}',function($userId,$filename){
$path = public_path("upload/users/{$userId}/{$filename}");
if(!\File::isFile($path)){
abort(404,"Dosya bulunamadı !");
}
$file = \File::get($path);
$response = \Response::make($file,200);
$response->header('Content-Type', 'image/png');
return $response;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment