Skip to content

Instantly share code, notes, and snippets.

@jechav
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jechav/c2a44638a75e4b70e635 to your computer and use it in GitHub Desktop.
Save jechav/c2a44638a75e4b70e635 to your computer and use it in GitHub Desktop.
Laravel public_path() setup images upload
# 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');
});
}
# 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