public function postAction() { $image = new Image(); $params = $this->get("request")->get("post"); if (!is_array($params) || !array_key_exists("name", $params)) { throw new RequestException("wrong file upload request"); } $image->set("path", $params["name"]); $image->save($this->get("connection")); return $this->allAction(); }
function uploadimage() { $file = Input::file('file'); $directory = public_path() . '/uploads/'; $extension = File::extension($file->getClientOriginalName()); $filename = uniqid() . '.' . $extension; $file->move($directory, $filename); $image = new Image(); $image->travel = -1; $image->name = $filename; $image->save(); return $filename; }