Skip to content

Instantly share code, notes, and snippets.

@caitlindaily
caitlindaily / img-upload
Last active August 29, 2015 14:03
Uploading images
//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);