File tree 1 file changed +18
-5
lines changed
src/Symfony/Component/HttpFoundation/File
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -214,13 +214,26 @@ public function move($directory, $name = null)
214
214
*/
215
215
public static function getMaxFilesize ()
216
216
{
217
- $ iniMax = strtolower (ini_get ('upload_max_filesize ' ));
217
+ $ sizePostMax = self ::parseFilesize (ini_get ('post_max_size ' ));
218
+ $ sizeUploadMax = self ::parseFilesize (ini_get ('upload_max_filesize ' ));
218
219
219
- if ('' === $ iniMax ) {
220
- return PHP_INT_MAX ;
220
+ return min ([$ sizePostMax , $ sizeUploadMax ]);
221
+ }
222
+
223
+ /**
224
+ * Returns the given size from an ini value in bytes.
225
+ *
226
+ * @return int The given size in bytes
227
+ */
228
+ private static function parseFilesize ($ size )
229
+ {
230
+ if ('' === $ size ) {
231
+ return 0 ;
221
232
}
222
233
223
- $ max = ltrim ($ iniMax , '+ ' );
234
+ $ size = strtolower ($ size );
235
+
236
+ $ max = ltrim ($ size , '+ ' );
224
237
if (0 === strpos ($ max , '0x ' )) {
225
238
$ max = \intval ($ max , 16 );
226
239
} elseif (0 === strpos ($ max , '0 ' )) {
@@ -229,7 +242,7 @@ public static function getMaxFilesize()
229
242
$ max = (int ) $ max ;
230
243
}
231
244
232
- switch (substr ($ iniMax , -1 )) {
245
+ switch (substr ($ size , -1 )) {
233
246
case 't ' : $ max *= 1024 ;
234
247
// no break
235
248
case 'g ' : $ max *= 1024 ;
You can’t perform that action at this time.
0 commit comments