Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- if (array_key_exists('uploaded_files', $_FILES)) {
- //Attach multiple files one by one
- for ($i = 0; $i < count($_FILES['uploaded_files']['tmp_name']); $i++) {
- if ($i == $maximumfiles) {
- throw new RuntimeException('<div class="alert">Sie haben zuviele Dateien hochgeladen.</div>');
- }
- if (!isset($_FILES['uploaded_files']['error'][$i])) {
- throw new RuntimeException('<div class="alert">Etwas mit Ihren Dateien stimmt nicht.</div>');
- }
- switch ($_FILES['uploaded_files']['error'][$i]) {
- case UPLOAD_ERR_OK:
- break;
- // case UPLOAD_ERR_NO_FILE:
- // throw new RuntimeException('<div class="alert">Eine Ihrer Dateien scheint nicht verschickt worden zu sein.</div>');
- case UPLOAD_ERR_INI_SIZE:
- case UPLOAD_ERR_FORM_SIZE:
- throw new RuntimeException('<div class="alert">Eine Ihrer Dateien scheint von der Datenmenge groß zu sein.</div>');
- // default:
- // throw new RuntimeException('<div class="alert">Ein unbekannter Fehler ist aufgetreten.</div>');
- }
- if ($_FILES['uploaded_files']['size'][$i] > 5000000) {
- throw new RuntimeException('<div class="alert">Die maximale Dateigröße ist überschritten.</div>');
- }
- // if(in_array($finfo->file($_FILES['uploaded_files']['tmp_name'][$i]), $acceptedMime, true) === false){
- // throw new RuntimeException('<div class="alert">Invalid file format.</div>');
- // }
- // if (false === $ext = array_search(
- // $finfo->file($_FILES['uploaded_files']['tmp_name'][$i]),
- // array(
- // 'jpg' => 'image/jpeg',
- // 'png' => 'image/png',
- // 'gif' => 'image/gif',
- // 'pdf' => 'application/pdf',
- // ),
- // true
- // )) {
- // throw new RuntimeException('<div class="alert">Invalid file format.</div>');
- // }
- $uploadfile = $_FILES['uploaded_files']['tmp_name'][$i];
- $filename = $_FILES['uploaded_files']['name'][$i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment