简体   繁体   中英

Check if any of uploaded files in files array is bigger than 256mb

I need to check if any file in $_FILES array is bigger than 256mb . If it were JavaScript, I would use array.some() , but in PHP there is no such function.

if ($_FILES['upload-file']['size'][0] > 256000000 && $_FILES['upload-file']['size'][1] > 256000000 && ...) {
    $errors['size'] = "Файл превышает максимальный размер. Попробуйте сжать файл или загрузить его в Google Drive.";
  }

Found out using foreach.

foreach($_FILES['upload-file']['size'] as $files){
    if($files > 256000000) {
    $errors['size'] = "Файл превышает максимальный размер. Попробуйте сжать файл или загрузить его в Google Drive.";
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM