* [refac bug #65215] Check upload file for import.

This commit is contained in:
wangyidong
2025-09-05 10:26:55 +08:00
parent 0fff7bf00f
commit 909dc1ca81
2 changed files with 14 additions and 5 deletions
+4 -2
View File
@@ -430,11 +430,13 @@ class caselib extends control
{
$this->loadModel('testcase');
if($_FILES)
if($_POST)
{
$file = $this->loadModel('file')->getUpload('file');
$file = $file[0];
if(empty($_FILES)) return $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormat));
if(empty($file[0])) return $this->send(array('result' => 'fail', 'message' => $this->lang->testcase->errorFileNotEmpty));
$file = $file[0];
if(!$file || (isset($file['extension']) && $file['extension'] != 'csv')) return $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormat));
$fileName = $this->file->savePath . $this->file->getSaveName($file['pathname']);
+10 -3
View File
@@ -1236,14 +1236,16 @@ class testcase extends control
{
$this->testcaseZen->checkProducts(); // 如果不存在产品,则跳转到产品创建页面。
if($_FILES)
if($_POST)
{
/* 获取上传的文件。 */
/* Get file. */
$file = $this->loadModel('file')->getUpload('file');
if(empty($_FILES)) return $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormat));
if(empty($file[0])) return $this->send(array('result' => 'fail', 'message' => $this->lang->testcase->errorFileNotEmpty));
$file = $file[0];
if(!$file || (isset($file['extension']) && $file['extension'] != 'csv')) return $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormat));
/* 移动上传的文件。 */
/* Move file. */
@@ -1957,9 +1959,14 @@ class testcase extends control
*/
public function importXmind(int $productID, string $branch)
{
if($_FILES)
if($_POST)
{
if($_FILES['file']['size'][0] == 0) return $this->send(array('result' => 'fail', 'message' => $this->lang->testcase->errorFileNotEmpty));
$file = $this->loadModel('file')->getUpload('file');
if(empty($_FILES)) return $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormat));
if(empty($file[0])) return $this->send(array('result' => 'fail', 'message' => $this->lang->testcase->errorFileNotEmpty));
$file = $file[0];
if(!$file || (isset($file['extension']) && $file['extension'] != 'xmind')) return $this->send(array('result' => 'fail', 'message' => $this->lang->file->errorFileFormat));
/* 保存xmind配置。*/
/* Sav xmind config. */