示例#1
0
 public function testGetExtensionUndefined()
 {
     $this->assertEquals(null, $this->mime->getExtension('undefined'));
 }
示例#2
0
 public static function detectFileExtension(UploadedFile $file)
 {
     if ($file->getClientOriginalExtension()) {
         return $file->getClientOriginalExtension();
     }
     $mimeTypes = new MimeTypes();
     $extension = $mimeTypes->getExtension(mime_content_type($file->getRealPath()));
     if ($extension) {
         if ($extension == 'jpeg') {
             return 'jpg';
         }
         return $extension;
     }
     return 'txt';
 }