Send email with video as attachment

Dear Kirbys

I am following this cookbook Forms with attachments | Kirby CMS
and everything works fine.

Now I want to change the allowed upload file type to a video (mov, mp4).

However, when selecting a .mov or mp4 file, the file processing does not work anymore.

The file error code is “1”, the file “type” is not detecting that it contains “video”, and I am lacking of debugging skills within controllers.

See the relevant part in the applications controller

   // loop through uploads and check if they are valid
    foreach ($uploads as $upload) {
      // make sure the user uploads at least one file
      if ($upload['error'] === 4) {
        $alerts[] = 'You have to attach at least one file';
        //  make sure there are no other errors
      } elseif ($upload['error'] !== 0) {
        // => here the error is always "1" !
        $alerts[] = 'The file could not be uploaded';
        // make sure the file is not larger than 10MB…
      } elseif ($upload['size'] > 10000000) {
        $alerts[] = $upload['name'] . ' is larger than 10 MB';
        // …and the file is a video (e.g. mp4)
      } elseif ($upload['type'] !== 'video/mp4') {
        $alerts[] = $upload['name'] . ' is not a MP4';
        // all valid, try to rename the temporary file
      } else {
        $name     = $upload['tmp_name'];
        $tmpName  = pathinfo($name);
        // sanitize the original filename
        $filename = $tmpName['dirname'] . '/' . F::safeName($upload['name']);

        if (rename($upload['tmp_name'], $filename)) {
          $name = $filename;
        }
        // add the files to the attachments array
        $attachments[] = $name;
      }
    }

Any help is highly appreciated.

Thanks a lot.

How large is the file to be uploaded?

what are you php.ini settings for

upload_max_filesize
memory_limit
post_max_size
max_input_time

You can check your current values for these settings with phpinfo().

Thank you !

Setting the following vars in .user.ini made it work on HostEurope
(and for local development changing the global PHP settings for file uploads in Herd)

post_max_size=20M
upload_max_filesize=20M