laravel框架图片上传
生活随笔
收集整理的這篇文章主要介紹了
laravel框架图片上传
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
function add(Da $req){
$file= $req->file("file"); //接前臺值
$tu=$file->getClientOriginalName(); //圖片路徑
$data=$file->move("image",$tu);
$all= $req->all(); 接收所有的值
$all['file']=$data;
$model=new User();
$res=$model->adddo($all);
if ($res){
return redirect()->route("admin.login")->with("mes","請重新登錄");
}
}
//model層 class User extends Author
{
public $table="Users";
public $timestamps=false;
function adddo($data){
$this->name=$data['name'];
$this->email=$data['email'];
$this->password=bcrypt($data['password']);
$this->file=$data['file'];
return $this->save();
}
$file= $req->file("file"); //接前臺值
$tu=$file->getClientOriginalName(); //圖片路徑
$data=$file->move("image",$tu);
$all= $req->all(); 接收所有的值
$all['file']=$data;
$model=new User();
$res=$model->adddo($all);
if ($res){
return redirect()->route("admin.login")->with("mes","請重新登錄");
}
}
//model層 class User extends Author
{
public $table="Users";
public $timestamps=false;
function adddo($data){
$this->name=$data['name'];
$this->email=$data['email'];
$this->password=bcrypt($data['password']);
$this->file=$data['file'];
return $this->save();
}
轉載于:https://www.cnblogs.com/maohongli/p/11115247.html
總結
以上是生活随笔為你收集整理的laravel框架图片上传的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么要用unittest
- 下一篇: # 起床困难综合症(二进制枚举+按位求贡