[ZBX-417] Image upload not working properly Created: 2008 Aug 08  Updated: 2017 May 30  Resolved: 2014 Apr 08

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 1.4.5
Fix Version/s: None

Type: Incident report Priority: Major
Reporter: Steve Ruiz Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 5
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos 4.5, zabbix 1.4.6, postgres 8.2.x
browser: tried both firefox 3 and safari


Attachments: Text File zabbix-1.6.6-postgres-image-fix.patch     Text File zabbix-1.8.2_mysql_image_fix.patch     File zabbix-1.8.5_mysql_image_fix.patch     PNG File zabbixerror.png    

 Description   

When trying to create a new image (icon for map), I get the following error when trying to display the image (i.e. it uploads ok, but does not display properly):

(main text of the image, html not included)
imagecreatefromstring() :Data is not in a recognized format [image.php:58]
imagepng(): supplied argument is not a valid Image resource [/include/config.inc.php:1683]
imagedestroy(): supplied argument is not a valid Image resource [/include/config.inc.php:1683]

To reproduce:
Go to general, images. Click on one of the icons to display, right click, save as.
Go back, click create new image, give it a name, and upload the png file you just downloaded. Should see these errors, at least with a postgres backend.



 Comments   
Comment by Steve Ruiz [ 2008 Aug 08 ]

This is what I see in place of the image I uploaded.

Comment by Steve Ruiz [ 2008 Aug 08 ]

Was able to get around this by changing line 124 in images.inc.php:

return DBexecute("insert into images (imageid,name,imagetyp e,image)". " values ($imageid,".zbx_dbstr($name).",".$i magetype.",'".$image."')");

Removed the zbx_dbstr($image) and replaced with just $image, since we already escaped it with pg_escape_bytea() function.

Comment by Julien Poumailloux [ 2009 Jul 29 ]

I was able to fix the issue, the previous code given by Steve Ruiz is buggy.

in function add_image from include/images.inc.php, replace:

else if($DB['TYPE'] == "POSTGRESQL")

{ $image = pg_escape_bytea($image); }

by
else if($DB['TYPE'] == "POSTGRESQL")

{ $image = pg_escape_bytea($image); return DBexecute("insert into images (imageid,name,imagetype,image)". " values ($imageid,".zbx_dbstr($name).",".$imagetype.",'".$image."')"); }

the point is that postgresql expect the $image part of the request to be between quotes ', while this is not required by mysql.

Sincerely,

Julien Poummailloux

Comment by Aron Ujvari [ 2009 Sep 21 ]

I would recommend the attached patch against Zabbix 1.6.6, but the same modification should work with oldaer version also.

This is an ugly hack required for PHP's PostgreSQL interface since pg_escape_bytea and pg_unescape_bytea are not inverse functions, so we are not able to get back the same binary information from the database as we loaded before without this patch.

It also contains a fix for update_image function, as we it needs zbs_dbstr($image) but not the extra quotes to allow updates. add_image function works the same way by default, this patch changes the update_image function to this way too.

Comment by Andrew Flannery [ 2010 Nov 04 ]

here's my 1.8.2 patch for the same issue with mysql.

Comment by gabhosh [ 2011 Aug 09 ]

Here is mine for 1.8.5 for the same mysql issue
greatly inspired from the precedent patch from Andrew

Comment by richlv [ 2011 Aug 21 ]

ZBX-4044 might affect this issue

Comment by Jc Duss [ 2011 Nov 23 ]

I've got the same troubles here with a mysql 5.1.49 and apache2.2.16
I was not affected with this problem since I upload from 1.8.3 to 1.8.8. (On 1.8.3 it was working fine).

my table images and database zabbix are set with utf8 charset.

I tried the patch for 1.8.5 here without success.

If I "tcpdump" the traffic, I can see that image is uploaded... but store in database is not done. The blob field in the tables remains empty. I tried with both PNG and JPG without success.

Can someone help me? What kind of information can I give you?

Nicolas

Comment by richlv [ 2014 Jan 14 ]

this should be fixed by now - is anybody seeing this with recent zabbix version and proper utf8 db ?

Comment by Ivo Kurzemnieks [ 2014 Apr 08 ]

Issue has been fixed in latest Zabbix versions and is no longer reproducible.

CLOSED.

Generated at Fri Apr 26 22:21:29 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.