Cannot retrieve attachments of any kind

I am able to attach a file to a History or Document, but I am unable to retrieve it. When I click on the attached filename, a new browser page appears and tells me is currently unable to handle this request. HTTP ERROR 500.

This happened on 7.7.9, and it continues on 7.8.0 (having just upgraded).

I know that the attachments are being saved and loaded into SuiteCRM, because I can go into the native file system (Windows 10 Enterprise) on the server where SuiteCRM is installed and access the files that I saved. These are Word, PDF and other file types. They all load just fine from the native file system, but not from SuiteCRM.

Has anyone else run into this problem, and how did you solve it???

-smbean

I have the exact same problem. The problem continues in 7.8.2 as well. The link to the file looks like:

https://xxx.myserver.com/index.php?entryPoint=download&id=117c76af-5b36-e8a2-be98-58e526003cb7&type=Notes

When I go to the upload directory and find the file (the name is the id), I can open it with the proper program.

Found the following in the error log after trying to retrieve an attachment:

[05-Apr-2017 14:21:32 America/New_York] PHP Notice: Undefined index: editor in \include\SugarFields\Fields\Text\SugarFieldText.php on line 89
[05-Apr-2017 14:21:32 America/New_York] PHP Notice: Undefined index: editor in \include\SugarFields\Fields\Text\SugarFieldText.php on line 89
[05-Apr-2017 14:21:32 America/New_York] PHP Warning: Illegal string offset ‘cookie_name’ in \cache\smarty\templates_c%%E2^E2B^E2BC33C5%%SubPanelTiles.tpl.php on line 41
[05-Apr-2017 14:21:35 America/New_York] PHP Notice: Undefined offset: 1 in \download.php on line 110
[05-Apr-2017 14:21:35 America/New_York] PHP Fatal error: Uncaught Error: Call to undefined function mime_content_type() in \download.php:174
Stack trace:
#0 \include\MVC\Controller\SugarController.php(864): require_once()
#1 \include\MVC\Controller\SugarController.php(394): SugarController->handleEntryPoint()
#2 \include\MVC\Controller\SugarController.php(307): SugarController->process()
#3 \include\MVC\SugarApplication.php(105): SugarController->execute()
#4 \index.php(52): SugarApplication->execute()
#5 {main}
thrown in \download.php on line 174

Ok, I found my issue. I’m running on PHP 7. The download.php (in the root of the crm installation) is calling a deprecated function – mime_content_type(). I updated the download.php file with the following code:

    // Fix for issue 1506 and issue 1304 : IE11 and Microsoft Edge cannot display generic 'application/octet-stream' (which is defined as "arbitrary binary data" in RFC 2046).
    
	//added this manually
	if (!function_exists('mime_content_type'))
	{
		function mime_content_type($f)
		{
			return trim(exec('file -bi ' . escapeshellarg($f)));
		}
	}
	//end of added content
	
	$mime_type = mime_content_type($local_location);
	
    if($mime_type == null || $mime_type == '') {
        $mime_type = 'application/octet-stream';
    }
1 Like

You need to enable fileinfo -
Are you using windows? If so add extension=php_fileinfo.dll to php.ini.
mime_content_type is not deprecated also.

Is there a list of extensions somewhere with all that are required by SuiteCRM?

I guess I got misinformation on the function:
https://codedump.io/share/rvzD73w15epC/1/why-is-mimecontenttype-deprecated-in-php

Hi.

I have the same issue when i tried to download an attachment i got the error

Fatal error: Call to undefined function mime_content_type() on line 174

So i went to that file and edited that line:


$mime_type = mime_content_type($local_location);
        if($mime_type == null || $mime_type == '') {
            $mime_type = 'application/octet-stream';
}

I comented that block, so i can download the file, but i don’t know if this is a good solution or what security hole open.

Thanks.

Hi everyone, the changes suggested in this thread worked just fine for me… until the latest patch (7.10.4).

Anyone else checked theirs still works?