Mautic Community Forums

[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)) {
        return;
    }
    $exif = exif_read_data($filename);
    if (empty($exif['Orientation'])) {
        return;
    }
    $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);
                break;

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

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

}

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

Screenshot
image

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.

Thoughts?
Matthew

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.
WHM/CPANEL Server.

Hi,
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?
Thx,
Joey

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…
M