File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,19 @@ public function getClientOriginalName()
118
118
return $ this ->originalName ;
119
119
}
120
120
121
+ /**
122
+ * Returns the original file extension
123
+ *
124
+ * It is extracted from the original file name that was uploaded.
125
+ * Then is should not be considered as a safe value.
126
+ *
127
+ * @return string The extension
128
+ */
129
+ public function getClientOriginalExtension ()
130
+ {
131
+ return pathinfo ($ this ->originalName , PATHINFO_EXTENSION );
132
+ }
133
+
121
134
/**
122
135
* Returns the file mime type.
123
136
*
Original file line number Diff line number Diff line change @@ -89,6 +89,20 @@ public function testGetClientOriginalName()
89
89
$ this ->assertEquals ('original.gif ' , $ file ->getClientOriginalName ());
90
90
}
91
91
92
+ public function testGetClientOriginalExtension ()
93
+ {
94
+ $ file = new UploadedFile (
95
+ __DIR__ .'/Fixtures/test.gif ' ,
96
+ 'original.gif ' ,
97
+ 'image/gif ' ,
98
+ filesize (__DIR__ .'/Fixtures/test.gif ' ),
99
+ null
100
+ );
101
+
102
+ $ this ->assertEquals ('gif ' , $ file ->getClientOriginalExtension ());
103
+ }
104
+
105
+
92
106
/**
93
107
* @expectedException Symfony\Component\HttpFoundation\File\Exception\FileException
94
108
*/
You can’t perform that action at this time.
0 commit comments