public function postImage() { $file = Input::file('file'); // your file upload input field in the form should be named 'file' $lp_id = Input::get('lp_id'); $vid = Input::get('vid'); $tid = Input::get('tid'); $var = $this->variant->find($vid); $landing = $this->variant->getlandingname($lp_id); $destinationPath = 'sliders/' . $landing . '/' . $var->id . '/'; $filename = $file->getClientOriginalName(); //$extension =$file->getClientOriginalExtension(); //if you need extension of the file $uploadSuccess = Input::file('file')->move($destinationPath, $filename); $fullpath = $destinationPath . $filename; $sid = $this->variant->insertslider($tid, $vid, $landing); $asdf = $this->variant->insertimages($sid, $fullpath, $filename); if ($uploadSuccess) { return Response::json('success', 200); // or do a redirect with some message that file was uploaded } else { return Response::json('error', 400); } }
public function getfoldername($vid) { $variant = Variant::find($vid); $name = str_replace(' ', '_', $variant->name); $name = strtolower($name); $landingname = Variant::getlandingname($variant->id); return $landingname . '/' . $name; }