/** * Tests getRealType * * @issue 1442 * @author Serghei Iakovlev <*****@*****.**> * @author Dreamszhu <*****@*****.**> * @since 2013-10-26 */ public function testRealType() { if (!extension_loaded('fileinfo')) { $this->markTestSkipped('Warning: fileinfo extension is not loaded'); } $this->specify("getRealType does not returns real type", function () { $file = new File(['name' => 'test', 'type' => 'text/plain', 'tmp_name' => PATH_DATA . '/assets/phalconphp.jpg', 'size' => 1, 'error' => 0]); expect($file->getType())->equals('text/plain'); expect($file->getRealType())->equals('image/jpeg'); }); }
/** * Check file allowed extensions * * @param \Phalcon\Http\Request\File $file * @param mixed $value * @return bool */ public function checkMimes(\Phalcon\Http\Request\File $file, $value) { //conversion to the desired format if (is_array($value) === false) { $value = [$value]; } if (in_array($file->getRealType(), $value) === false) { $this->errors[] = sprintf(Message::get('INVALID_MIME_TYPES'), $file->getName(), implode(',', $value)); return false; } return true; }
public function getRealType() { return parent::getRealType(); }