Suitecrm: Logo upload function is not working

Created on 21 Oct 2016  Â·  62Comments  Â·  Source: salesagility/SuiteCRM

Issue

The logo upload function is not working. A message with the type of supported images is shown even though a supported image is uploaded.

Expected Behavior

The logo image should be uploaded.

Actual Behavior

A message indicating supported image types is shown.

Possible Fix

The variable '$upload->temp_file_location' includes a path with the extension 'tmp' in the file 'modules/Configurator/UploadFileCheck.php'

Steps to Reproduce

  1. Login
  2. Go to the administration section
  3. Click on system settings
  4. Attempt to upload a image with a supported extension

image

Context

I was trying to change the logo that is shown on the login screen of SuiteCRM.

Your Environment

SuiteCRM 7.7.4 using Microsoft SQL Server and PHP 7 on IIS.

Moderate Fix Proposed Bug

Most helpful comment

The_irony,_that_after_years_with_this_issue,_and_16_participants_here,_and_dozens_of_comments,_in_the_end_the_issue_is_spaces_in_the_filename._I'm_dumping_spaces_altogether,_from_now_on

All 62 comments

Can you please try 7.7.6 ? I think 7.7.5 addressed that issue.
Note: there is no point to find bugs on older versions as they may be solved!

Related: https://github.com/salesagility/SuiteCRM/issues/502

The issue has been tested in recent version of SuiteCRM(7.7.6), and it not appear,
@saleembdr , can you confirm is this not issue any more in recent version of SuiteCRM, if yes can you close an issue.
Thanks for your contribution.

Hi,
I am using SuiteCRM V7.7.6. and the problem still occurs. I have tried .jpeg and .png.
The images have a max. height aof 170px and a width of 368px and even smaller and the message described shows.
error_message
version

I have installed the version 7.7.6 for testing. The same message is encountered while trying to upload a JPEG image for the logo. The following screen-shot provides more information.

image

@saleembdr , just quick question, did you try with another images, and extensions? like take some pictures with different size .jpg .jpeg .png, and try out?
Thanks for your contribution.

@shogunpol. I tried downloading the logo that is currently used on the system and uploading it again. The same message was encountered. The downloaded logo from the application that is on the login page is named 'company_logo.png'.

@saleembdr , i just ask different question, use any other pictures with above described extensions.
Thanks for your contribution.

@shogunpol well you didn't ask me, but I tried several pictures with different extensions and sizes. Always the same problem.

@shogunpol as I understand you are involved in the development. Can you send me the structur of the programm, so I can take a look by myself what could be the problem ?

@Ninidelaogong , you can download recent version of SuiteCRM(7.7.6), on:
https://suitecrm.com/download/suitecrm.
Thanks for your contribution

@Ninidelaogong. You can temporarily fix the problem by adding 'tmp' to the array in the following statement:

$supportedExtensions = array('jpg', 'png', 'jpeg');

This statement is in the file 'modules/Configurator/UploadFileCheck.php'. You can remove the 'tmp' value after uploading the image. Keeping the value 'tmp' will cause SuiteCRM to accept any file type for uploads.

@saleembdr thanks for the hint. I tried but it didn't work with my installation. I didn't get the error message anymore but there was also no upload.
I found out that the same problem is with sugarcrm.

@Ninidelaogong. Print the value in the field '$upload->temp_file_location' of the 'UploadFileCheck' file. The file extension in this path should be temporarily added to the array.

After additional information, i been able to replicate an issue in recent version of SuiteCRM(7.7.6),
the issue appear only in MSSQL.
@saleembdr , we label this issue as a "Bug"
thanks for your contribution.

@Ninidelaogong. I was mistaken about the file that can be changed for a temporary fix. The correct file to change temporarily is 'include\utils.php'. The following statement is the one that can be changed by adding the 'tmp' value mapping:

$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg');

The statement can be changed to the following:

$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'tmp' => 'tmp' );

@saleembdr perfect thank you so much, works perfectly.

@saleembdr , may i ask you to test this issue on our official demo instance? if is work?
http://demo.suiteondemand.com/index.php?action=Login&module=Users

@shogunpol confirmed in 7.8 beta: can't upload a new logo.
I can upload a logo when installing (the install screen) but I can't change the logo later (using Admin / system settings)
The message is the same as above "its not a jpeg or png."
Note: I even tested to upload the same image used ok when installing, so its not the image.

Note: I couldn't reproduce this in your demo because we don't have a full admin access (to system settings).

Suggestion: there should be an option to delete the actual logo!

I was also not able to test this on the demo instance because I do not have access to the administration section.

just to add precision, I installed a brand new test instance of 7.8.3 and the problem remains...

Problem still remains in Versão 7.9.4

In duplicate issue #5530 user @kanagaraj1305 suggests it's a problem with the security verification condition here:

https://github.com/salesagility/SuiteCRM/blob/master/include/utils.php#L5089

I am having this issue on a fresh install of 7.10.10

It is a brand new installation. Everything else seems to be working so far.
I have a jpg logo that each time I try to upload it it gives me the error:

The file format of the image must be JPEG or PNG. Upload a new file with the file extension .jpg or .png.

It's painful. I gave up.

Sent from my Samsung Galaxy smartphone.
-------- Original message --------From: Ricardo notifications@github.com Date: 11/29/18 10:28 (GMT+00:00) To: salesagility/SuiteCRM SuiteCRM@noreply.github.com Cc: Spencer Shaw spencer@streetlike.com, Comment comment@noreply.github.com Subject: Re: [salesagility/SuiteCRM] Logo upload function is not working
  (#2464)
I am having this issue on a fresh install of 7.10.10

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/salesagility/SuiteCRM","title":"salesagility/SuiteCRM","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/salesagility/SuiteCRM"}},"updates":{"snippets":[{"icon":"PERSON","message":"@maverick85 in #2464: I am having this issue on a fresh install of 7.10.10"}],"action":{"name":"View Issue","url":"https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-442783787"}}}
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-442783787",
"url": "https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-442783787",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [salesagility/SuiteCRM] Logo upload function is not working (#2464)",
"sections": [
{
"text": "",
"activityTitle": "Ricardo",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@maverick85",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"salesagility/SuiteCRM\",\n\"issueId\": 2464,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"salesagility/SuiteCRM\",\n\"issueId\": 2464\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-442783787"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 175411215\n}"
}
],
"themeColor": "26292E"
}
]

I am having this issue on a fresh install of 7.10.10

It is a brand new installation. Everything else seems to be working so far.
I have a jpg logo that each time I try to upload it it gives me the error:

The file format of the image must be JPEG or PNG. Upload a new file with the file extension .jpg or .png.

Check a possible resolution in my comment on the 28 of October 2016.

Maybe an easier workaround is to just go into the server using a shell and replacing the file

themes/default/images/company_logo.png

and making sure it has read access by your web server...

I have freshly installed the latest version:
Version 7.10.11
Sugar Version 6.5.25 (Build 344)

When I upload the image, image gets uploaded but it does not reflect the website. i.e. company logo does not change. Please guide me.

We gave up. Loads of bugs in the software.

Sent from my Samsung Galaxy smartphone.
-------- Original message --------From: Amir Mustafa notifications@github.com Date: 1/8/19 08:35 (GMT+00:00) To: salesagility/SuiteCRM SuiteCRM@noreply.github.com Cc: Spencer Shaw spencer@streetlike.com, Comment comment@noreply.github.com Subject: Re: [salesagility/SuiteCRM] Logo upload function is not working
  (#2464)
I have freshly installed the latest version:

Version 7.10.11

Sugar Version 6.5.25 (Build 344)
When I upload the image, image gets uploaded but it does not reflect the website. i.e. company logo does not change. Please guide me.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/salesagility/SuiteCRM","title":"salesagility/SuiteCRM","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/salesagility/SuiteCRM"}},"updates":{"snippets":[{"icon":"PERSON","message":"@AmirMustafa in #2464: I have freshly installed the latest version:\r\nVersion 7.10.11 \r\nSugar Version 6.5.25 (Build 344)\r\n\r\nWhen I upload the image, image gets uploaded but it does not reflect the website. i.e. company logo does not change. Please guide me."}],"action":{"name":"View Issue","url":"https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-452215890"}}}
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-452215890",
"url": "https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-452215890",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]

Ohhh.. thanks for the update Spencer :)

7.5.11
tried all the suggestions above. still cant upload logo during install. would be nice to get resolution at some point. for now, i'll just change it in the fs.

I'm afraid this can't be fixed if it can't be reproduced...

If one of you can please provide

  • a specific image file you used and triggered this issue
  • what messages did you get in your logs during that upload
  • basic version info: SuiteCRM, PHP, Database

Thanks.

Same problem in 7.11.5, 7.11.6. There is some workaround to this issue?

@mauriciocano can you provide the information I asked for in my last comment?

  1. I tried to recreate my logo according to dimensions of SuiteCRM logo, saved as .png and .jpeg but both files did not upload, I still received the same error message.

  2. I subsequently downloaded SuiteCRM logo and re-uploaded it again, it was uploaded.

Is there still no possible fix?

I'm afraid this can't be fixed if it can't be reproduced...

If one of you can please provide

  • a specific image file you used and triggered this issue
  • what messages did you get in your logs during that upload
  • basic version info: SuiteCRM, PHP, Database

Thanks.

On number 2 of your list this is the log:

Thu Jul 11 20:49:40 2019 [341750][1][FATAL] A user (1) attempted to use an invalid file for the logo - upload://tmp_logo_company_upload/CRM%20Logo%20Test.jpg
Thu Jul 11 20:50:11 2019 [349043][1][FATAL] A user (1) attempted to use an invalid file for the logo - upload://tmp_logo_company_upload/CRM%20Logo%20Test.png

Number 3:

Version 7.10.17
Sugar Version 6.5.25 (Build 344) on PHP Version 7.3

This won't go anywhere until somebody provides what is being asked, sorry. If you have a file that doesn't work, please provide it so I can reproduce the problem here. It's simple, but for some reason weeks go by and nobody is able to give me what I asked for...

If you don't want to put the file up publicly, email it to [email protected]

Thanks

This won't go anywhere until somebody provides what is being asked, sorry. If you have a file that doesn't work, please provide it so I can reproduce the problem here. It's simple, but for some reason weeks go by and nobody is able to give me what I asked for...

https://drive.google.com/file/d/1CUQxasBdQRkrl7frYpUqJ7DVXFF6crYn/view?usp=sharing

@MyBlissIT Thanks! I've just replicated this using your image. The problem is the space in the filename, as a temporary workaround, you should be able to remove it and upload as normal.

The_irony,_that_after_years_with_this_issue,_and_16_participants_here,_and_dozens_of_comments,_in_the_end_the_issue_is_spaces_in_the_filename._I'm_dumping_spaces_altogether,_from_now_on

@MyBlissIT Thanks! I've just replicated this using your image. The problem is the space in the filename, as a temporary workaround, you should be able to remove it and upload as normal.

@pgorod you telling me the fix is naming a file as "CompanyLogo.jpeg" instead of "Company Logo.jpeg"

To be more precise, Dillon is telling you that, not me :-)

I removed the space on the filename and I believe the file is uploaded because I do not recieve the error message.

However, the SuiteCRM logo still appears on my Log In page + dashboard.

I uploaded via System Settings -> Select Logo

Quick Repair and rebuild
Ctrl-F5 in the browser to refresh

Interesting, I'm able to replicate that as well (Image uploads but still shows the old one), it looks like @pgorod is right and a hard browser refresh fixes it though.

Quick Repair and rebuild
Ctrl-F5 in the browser to refresh

fixed!!! thanks

Now, How do I remove the SuiteCRM on the top left of the dashboard?

image

Now, How do I remove the SuiteCRM on the top left of the dashboard?

image

I would possibly like to have my own Favicon as well

Please search the Forums for those answers, that is not part of this bug here. Thanks for you help debugging this.

Thank you @Dillon-Brown , you assisted me on 2 bug issues today.

The_irony,_that_after_years_with_this_issue,_and_16_participants_here,_and_dozens_of_comments,_in_the_end_the_issue_is_spaces_in_the_filename._I'm_dumping_spaces_altogether,_from_now_on

Lets hope this is solved now. Only to remember that initially the bug also affected no space files!
I confirm the bug. Tried both JPG and PNG with several sizes, no space or no non-alpanumeric.
https://github.com/salesagility/SuiteCRM/issues/502#issuecomment-167022664

nope, still not working for me.
sebsspace

same image worked when I chose it during install, but I reinstalled and left that option, now it won't update

@macktic Interesting, my initial assumption would be permissions but I'll give this a try on Monday with your image and see if I can replicate.

In xampp with SuiteCRM 7.10.20 (I don't know if in other cases too) the error is in /include/utils.php
function verify_uploaded_image(...
`
{
$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg');
if (!$jpeg_only) {
$supportedExtensions['png'] = 'image/png';
}

if (!file_exists($path) || !is_file($path)) {
    return false;
}

$img_size = getimagesize($path);
$filetype = $img_size['mime'];
$tmpArray = explode('.', $path);
$ext = end($tmpArray);

if (substr_count('..', $path) > 0 || ($ext !== $path && !isset($supportedExtensions[strtolower($ext)])) ||
        !in_array($filetype, array_values($supportedExtensions))
) {
    return false;
}

`
Pay attention that $supportedExtensions[] are: jpg, jpeg and png
BUT the temporary file created after upload has tmp extension.

That is why this function always returns false.

For quick fix you can add "tmp" extension to this function as valid, or change the upload file name to have correct extension in tmp directory.
I think it would be best to add tmp extension to $supportedExtensions, since the file type gets validated anyway in this sentence:
!in_array($filetype, array_values($supportedExtensions))

Regards,
Roman.

Hi all, I'm still having the same issue. I'm ussing SuiteCRM Versión 7.11.10 Sugar Versión 6.5.25 (Preparado 344) and the logo file attached. All is running in Windows.
Any help Will be appreciatted. Thanks.
LogoIFF

Hi all, I'm still having the same issue. I'm ussing SuiteCRM Versión 7.11.10 Sugar Versión 6.5.25 (Preparado 344) and the logo file attached. All is running in Windows.
Any help Will be appreciatted. Thanks.
LogoIFF

@Santosgusta2010 Did you try the solution I proposed in https://github.com/salesagility/SuiteCRM/issues/2464#issuecomment-536640697 ?
Like, this:
Open /include/utils.php
Edit function verify_uploaded_image(...
Change:
$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg');
To:
$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'tmp' => 'tmp');
Save and test.
Be careful, this change is not update-safe in SuiteCRM, but once you change the logo, you won't need this function.

Hi all, I'm still having the same issue. I'm ussing SuiteCRM Versión 7.11.10 Sugar Versión 6.5.25 (Preparado 344) and the logo file attached. All is running in Windows.
Any help Will be appreciatted. Thanks.

@Santosgusta2010 Did you try the solution I proposed in #2464 (comment) ?
Like, this:
Open utils.php
Edit function verify_uploaded_image(...
Change:
$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg');
To:
$supportedExtensions = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'tmp' => 'tmp');
Save and test.
Be careful, this change is not update-safe in SuiteCRM, but once you change the logo, you won't need this function.

Hi, I'm not sure where the utils.php files is located. I changed content on the file UploadFileCheck.php

Hi, I'm not sure where the utils.php files is located. I changed content on the file UploadFileCheck.php

Sorry about that, I updated the response to include the directory:
/include/uptils.php
And what did you change in UploadFileCheck.php? Did it work?

Hi, I'm not sure where the utils.php files is located. I changed content on the file UploadFileCheck.php

Sorry about that, I updated the response to include the directory: <-- Don't worry
/include/uptils.php
And what did you change in UploadFileCheck.php? Did it work?

I changed modules\Configurator\UploadFileCheck.php and add 'tmp' to $supportedExtensions = array('jpg', 'png', 'jpeg','tmp'); but didn't work.
Now I've changed include/uptils.php as you say and is working now. Thanks for helping.

Can somebody make a PR with this change to the SupportedExtensions array?

Was this page helpful?
0 / 5 - 0 ratings