Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4470 from sasezaki/hotfix/ZF-12128

sync ZF1 svn r24807 - ZF-12128: File Upload validator should display file na...
  • Loading branch information...
commit 970dce7cb2b7d1faa69a74603ca1f41e82b5cb3d 2 parents ada8301 + dba0bde
Matthew Weier O'Phinney weierophinney authored
18 library/Zend/Validator/File/Upload.php
View
@@ -163,40 +163,40 @@ public function isValid($value, $file = null)
switch ($content['error']) {
case 0:
if (!is_uploaded_file($content['tmp_name'])) {
- $this->throwError($file, self::ATTACK);
+ $this->throwError($content, self::ATTACK);
}
break;
case 1:
- $this->throwError($file, self::INI_SIZE);
+ $this->throwError($content, self::INI_SIZE);
break;
case 2:
- $this->throwError($file, self::FORM_SIZE);
+ $this->throwError($content, self::FORM_SIZE);
break;
case 3:
- $this->throwError($file, self::PARTIAL);
+ $this->throwError($content, self::PARTIAL);
break;
case 4:
- $this->throwError($file, self::NO_FILE);
+ $this->throwError($content, self::NO_FILE);
break;
case 6:
- $this->throwError($file, self::NO_TMP_DIR);
+ $this->throwError($content, self::NO_TMP_DIR);
break;
case 7:
- $this->throwError($file, self::CANT_WRITE);
+ $this->throwError($content, self::CANT_WRITE);
break;
case 8:
- $this->throwError($file, self::EXTENSION);
+ $this->throwError($content, self::EXTENSION);
break;
default:
- $this->throwError($file, self::UNKNOWN);
+ $this->throwError($content, self::UNKNOWN);
break;
}
}
26 tests/ZendTest/Validator/File/UploadTest.php
View
@@ -249,4 +249,30 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileUploadErrorFileNotFound', $validator->getMessages()));
$this->assertContains("nofile.mo'", current($validator->getMessages()));
}
+
+ /**
+ * @group ZF-12128
+ */
+ public function testErrorMessage()
+ {
+ $_FILES = array(
+ 'foo' => array(
+ 'name' => 'bar',
+ 'type' => 'text',
+ 'size' => 100,
+ 'tmp_name' => 'tmp_bar',
+ 'error' => 7,
+ )
+ );
+
+ $validator = new File\Upload;
+ $validator->isValid('foo');
+
+ $this->assertEquals(
+ array(
+ 'fileUploadErrorCantWrite' => "File 'bar' can't be written",
+ ),
+ $validator->getMessages()
+ );
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.