Last active
August 29, 2015 14:27
-
-
Save jechav/c2a44638a75e4b70e635 to your computer and use it in GitHub Desktop.
Laravel public_path() setup images upload
This file contains 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
# bootstrap/app.php | |
//if production .env set APP_PUBLIC=../hogarExperto/ for example | |
if(env('APP_PUBLIC') != NULL){ | |
$app->bind('path.public', function() { | |
return base_path().env('APP_PUBLIC'); | |
}); | |
} |
This file contains 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
# app/Http/Controllers/productController | |
$filename = $product->name.'.'.$file->getClientOriginalExtension(); | |
$path = "/images/products/"; | |
$file->move(public_path().$path, $filename); | |
$product->url_img = $path.$filename; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment