Last active
August 29, 2015 14:03
-
-
Save caitlindaily/c37c1c118b8b8632f6e8 to your computer and use it in GitHub Desktop.
Uploading images
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
//Creating path and directory for files to live--will live under public dir and then the name we give the next dir | |
//To make image name unique, apply post id to the image's origianl name //--> public/img-upload/ | |
//Need to move newly named image into image dir that was created | |
//defines the image path. this is used when wanting to display image. ex:--> show.blade.php <img src="{{{ $post->img_path }}}" | |
public function addUploadedImage ($image) | |
{ | |
$systemPath = public_path() . '/' . $this->imgDir . '/'; | |
$imageName = $this->id . '-' . $image->getClientOriginalName();//--> 2-image.jpg | |
$image->move($systemPath, $imageName); | |
$this->img_path = '/' . $this->imgDir . '/' . $imageName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment