Search Our Database

How to fix Prestashop image upload issue (PHP exec() function blocked)

Last updated on |
by

Open up images.inc.php under web root folder and look for:

finfo_close($finfo);
    }

and

foreach ($types AS $type)

Copy the code below to your clipboard, and replace all the code between the two lines shown above

elseif (function_exists('mime_content_type'))
    $mimeType = mime_content_type($file['tmp_name']);

elseif (function_exists('exec00'))
{
    $mimeType = trim(exec('file -b --mime-type '.escapeshellarg($file['tmp_name'])));
    if (!$mimeType) $mimeType = trim(exec('file --mime '.escapeshellarg($file['tmp_name'])));
    if (!$mimeType) $mimeType = trim(exec('file -bi '.escapeshellarg($file['tmp_name'])));
}

if (empty($mimeType) OR $mimeType == 'regular file' OR $mimeType == 'text/plain')
    $mimeType = $file['type'];