예제 #1
0
 public function uploadLogo()
 {
     if ($_FILES['logo']['error']) {
         return false;
     }
     //uploading image
     $allowedImageTypes = array("image/pjpeg", "image/jpeg", "image/jpg", "image/png", "image/x-png", "image/gif");
     if (!in_array($_FILES['logo']['type'], $allowedImageTypes)) {
         $this->setError(Text::_('INSTL_ERROR_LOGO_FILE_TYPE'));
         return false;
     } else {
         if (!JFile::upload($_FILES['logo']['tmp_name'], JPATH_ROOT . '/uploads/logo/' . JFile::makeSafe($_FILES['logo']['name']))) {
             $this->setError(Text::_('INSTL_ERROR_UPLOAD_LOGO'));
             return false;
         }
     }
     return true;
 }
예제 #2
0
 /**
  * Test makeSafe method
  *
  * @param   string  $name        The name of the file to test filtering of
  * @param   array   $stripChars  Whether to filter spaces out the name or not
  * @param   string  $expected    The expected safe file name
  * @param   string  $message     The message to show on failure of test
  *
  * @return void
  *
  * @covers        Joomla\Filesystem\File::makeSafe
  * @dataProvider  dataTestMakeSafe
  * @since         1.0
  */
 public function testMakeSafe($name, $stripChars, $expected, $message)
 {
     $this->assertEquals($this->object->makeSafe($name, $stripChars), $expected, $message);
 }