上传图片加水印,本地可以,服务器报错

浏览:430 发布日期:2017/12/29 分类:求助交流
<h2>[1] <abbr title="think\exception\ErrorException">ErrorException</abbr> in <a class="toggle" title="/www/web/default/vendor/topthink/think-image/src/Image.php line 101">Image.php line 101</a></h2>
</div>
<div><h1>Call to a member function isFile() on null</h1></div>



代码如下:
$file = request()->file('file');
if(empty($file)){
$result["code"] = "1";
$result["msg"] = "请选择图片";
$result['data']["src"] = '';
}else{
// 移动到框架应用根目录/public/uploads/ 目录下
$info = $file->validate(['size' => 1000000, 'ext' => 'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'uploads');
if($info){
$image = \think\Image::open(request()->file('file'));

$width = $image->width();
$height = $image->height();
if($width>450&&$height>300){
$image->water('./public/before/img/logo.png',\think\Image::WATER_SOUTHEAST ,50)->save('./public/uploads/'. $info->getSaveName());
}
//成功上传后 获取上传信息
$result["code"] = '0';
$result["msg"] = "上传成功";
$result['data']["src"] = 'http://127.0.0.1/public/uploads/'.$info->getSaveName();
}else{
// 上传失败获取错误信息
$result["code"] = "2";
$result["msg"] = "上传出错";
$result['data']["src"] ='';
}
}
return json_encode($result);


大佬们,求原因,求办法啊
最佳答案
评论( 相关
后面还有条评论,点击查看>>