1
所以在上傳PHP文件我目前正在檢查對php.ini文件上傳大小錯誤時:是否有必要檢查文件大小對php.ini和手動?
switch ($_FILES['file']['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
throw new RuntimeException('No file sent.');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new RuntimeException('Exceeded filesize limit.');
default:
throw new RuntimeException('Unknown errors.');
}
,然後手動檢查他們:
$max_size = "10490000";
if ($_FILES['file']['size'] > $max_size) {
throw new RuntimeException('Exceeded filesize limit.');
}
是必要的第二步?或者只是檢查錯誤就足夠了。
另外,如果有必要,我可以放心地做這樣的事情了第二次檢查:
$max_size = (int)(ini_get('upload_max_filesize'));