提交文件上传提示文字

This commit is contained in:
吴昊天 2023-02-18 18:16:11 +08:00
parent 7416ff1a97
commit 52f7140be1
4 changed files with 16 additions and 16 deletions

View File

@ -126,17 +126,17 @@ class Cos extends BaseUpload
if (!$isStream) {
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());

View File

@ -113,17 +113,17 @@ class Local extends BaseUpload
{
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
if ($realName) {

View File

@ -121,17 +121,17 @@ class Oss extends BaseUpload
{
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());

View File

@ -117,17 +117,17 @@ class Qiniu extends BaseUpload
{
$fileHandle = app()->request->file($file);
if (!$fileHandle) {
return $this->setError('Upload file does not exist');
return $this->setError('上传的文件不存在');
}
if ($this->validate) {
if (!in_array(pathinfo($fileHandle->getOriginalName(), PATHINFO_EXTENSION), $this->validate['fileExt'])) {
return $this->setError('Upload fileExt error');
return $this->setError('不合法的文件后缀');
}
if (filesize($fileHandle) > $this->validate['filesize']) {
return $this->setError('Upload filesize error');
return $this->setError('文件过大');
}
if (!in_array($fileHandle->getOriginalMime(), $this->validate['fileMime'])) {
return $this->setError('Upload fileMine error');
return $this->setError('不合法的文件类型');
}
}
$key = $this->saveFileName($fileHandle->getRealPath(), $fileHandle->getOriginalExtension());