[embed form] issue with upload field / version 4.0.1

Your software
My Mautic version is: 4.0.1
My PHP version is: 7.4.x
My Database type and version is: mariadb

Your problem
We have a form which is embedded on another webiste. (using the js method, we have tested with iframe and custom script, all have same result)
CORS settings are all set correctly.

When a user submits the form and chooses the form field to upload a file (pdf, set in field settings)
The form does not submit and throws an error 500

These errors are showing in the log:
[2021-10-12 09:54:30] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Attempted to call function "exif_imagetype" from namespace "Mautic\FormBundle\Helper"." at /home/xxx/public_html/app/bundles/FormBundle/Helper/FormUploader.php line 154 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Attempted to call function \"exif_imagetype\" from namespace \"Mautic\\FormBundle\\Helper\". at /home/xxx/public_html/app/bundles/FormBundle/Helper/FormUploader.php:154)"} []

Steps I have tried to fix the problem:
Not sure where to start.

Try to upload a picture and see if you get the same error

This is what the error references:

 * Fix iOS picture orientation after upload PHP
 * https://stackoverflow.com/questions/22308921/fix-ios-picture-orientation-after-upload-php.
 * @param $filename
private function fixRotationJPG($filename)
    if (IMAGETYPE_JPEG != exif_imagetype($filename)) {
    $exif = exif_read_data($filename);
    if (empty($exif['Orientation'])) {
    $ort  = $exif['Orientation']; /*STORES ORIENTATION FROM IMAGE */
    $ort1 = $ort;
    $exif = exif_read_data($filename, 0, true);
    if (!empty($ort1)) {
        $image = imagecreatefromjpeg($filename);
        $ort   = $ort1;
        switch ($ort) {
            case 3:
                $image = imagerotate($image, 180, 0);

            case 6:
                $image = imagerotate($image, -90, 0);

            case 8:
                $image = imagerotate($image, 90, 0);
    imagejpeg($image, $filename, 90);


@EJL Thanks for the reply.
We tested with an image (PNG) and this did not work.


But our primary objective is to get a PDF uploaded, so not having this working is a concern.
I am not sure why we would have a check for an image if we are uploading a PDF.


That error indicates your browser is blocking based on cross-origins. Is your mautic installed on a subdomain or subdirectory of this particular site?

@EJL This instance is on the same server and using a subdomain.

What else do you have on this server?
Do you have Wordpress? If So do you have a WP plugin that maybe acts as firewall? Maybe Wordfence?

Hi @joeyk
as a matter of interest, could you try to upload a PDF and see if you get the same issue or if this works.
Image works on our side, but not the PDF…

@johan_jacobs this is the thread I mentioned in my email. @raramuridesign I tested adding the upload field on one of my forms and it works perfectly. I place my money on @joeyk’s comment above; so I have asked for the two WP sites to be removed from the web server.

@EJL @joeyk
I have created a test link with the form. If you fill out the details and try either a PDF or JPG you will see the form does not work.

We get some issue with server error, see console. But this still does not make any sense as there is a cross origin issue. We have tested this on a different server which does not have cpanel but vanilla setup. So we are trying to isolate the issue here.

If you could take a look that would be awesome

@joeyk @EJL Here is the error from the last test on that link

[2021-11-09 15:47:52] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Attempted to call function "exif_imagetype" from namespace "Mautic\FormBundle\Helper"." at /home/xxxx/public_html/app/bundles/FormBundle/Helper/FormUploader.php line 154 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Attempted to call function \"exif_imagetype\" from namespace \"Mautic\\FormBundle\\Helper\". at /home/xxxx/public_html/app/bundles/FormBundle/Helper/FormUploader.php:154)"} []

@joeyk @EJL Just wondering if you had a chance to relook at this error as per my note from Nov 21?

I tested the form, and I still see the cross origin issue with another URL ending with .cloud
You have to look into that for sure.

Hello @raramuridesign, see the comment above, have you managed to look into this for us yet? We need to get this upload field working soonest, thanks!

Here is an update after many hours of checking into why this happend!
Firstly, this had nothing to do with CORS. Although a different issue entirely.

Secondly, the server is running WHM/CPANEL environment.
Managed by the Hosting company, the default - chosen install by the host is to omit the very important module called - exif.

exif is required to understand the file types when uploaded by mautic.

Once this was installed and activated - the remote form embed worked without any issues.

There is an open issue on github to address the minimum requirements for Mautic, as a pre-install check. I hope this is also included soon, so these type of issues are addressed at installation, rather than when the mautic app is in full production mode.

reference: Mautic allows you to install with missing PHP modules · Issue #10805 · mautic/mautic · GitHub

1 Like