//添加数据处理
public function store()
{
$data['user_id'] = $_POST['user_id'];
$data['password'] =md5($_POST['password'].'shequteam');
//图片处理
$picture = $_FILES['picture'];
if($picture != ""){
$picture_ext = strtolower(substr($picture['name'],strrpos($picture['name'],'.')+1));
$filename = time() . rand(1000,9999) . "." . $picture_ext;
//默认添加文件路径 /upload/images/
$path = public_path().'/upload/images/'.date('Y-m-d');
if (!file_exists($path)) {
@mkdir($path);
}
if(move_uploaded_file($picture['tmp_name'],$path.'/'.$filename)){
$data['picture'] ='images/'.date('Y-m-d').'/'.$filename;//返回文件路径存贮在数据库
}
}
print_r($data);
die;
//消息提醒
//第一种
admin_toastr('自提点添加成功');
return redirect('/admin/merchants');
//第二种
$error = new MessageBag([
'title' => '自提点',
'message' => '添加失败',
]);
return redirect('/admin/merchants')->with(compact('error'));
}
//修改数据处理
public function update($id)
{
}
laravel-admin 自定义添加数据并处理上传图片事件
最新推荐文章于 2024-06-26 08:47:01 发布