1.后台是自己人使用,为了安全,线上商城,可以把后台隐藏起来访问(后台是独立的访问域名),
在运维方面对后台的访问进行限制。
2.我在加一个图片文件后缀的检测
3.对于yii2对图片的验证,
@yii\validators\ImageValidator;
/**
* Validates an image file.
* @param UploadedFile $image uploaded file passed to check against a set of rules
* @return array|null the error message and the parameters to be inserted into the error message.
* Null should be returned if the data is valid.
*/
protected function validateImage($image)
{
if (false === ($imageInfo = getimagesize($image->tempName))) {
return [$this->notImage, ['file' => $image->name]];
}
list($width, $height) = $imageInfo;
if ($width == 0 || $height == 0) {
return [$this->notImage, ['file' => $image->name]];
}
if ($this->minWidth !== null && $width < $this->minWidth) {
return [$this->underWidth, ['file' => $image->name, 'limit' => $this->minWidth]];
}
if ($this->minHeight !== null && $height < $this->minHeight) {
return [$this->underHeight, ['file' => $image->name, 'limit' => $this->minHeight]];
}
if ($this->maxWidth !== null && $width > $this->maxWidth) {
return [$this->overWidth, ['file' => $image->name, 'limit' => $this->maxWidth]];
}
if ($this->maxHeight !== null && $height > $this->maxHeight) {
return [$this->overHeight, ['file' => $image->name, 'limit' => $this->maxHeight]];
}
return null;
}
也是使用了函数 getimagesize