Last active
June 22, 2016 09:12
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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